cline / strongly-typed-id
Strongly-typed ID value objects for PHP with support for UUID, ULID, NanoID, GUID, Sqid, Hashids and Laravel integration
Installs: 1 000
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/cline/strongly-typed-id
Requires
- php: ^8.5.0
- hashids/hashids: ^5.0.2
- spatie/laravel-data: ^4.18.0
- spatie/laravel-package-tools: ^1.92.7
- sqids/sqids: ^0.5.0
Requires (Dev)
- cline/coding-standard: ^1.5.7
- ergebnis/composer-normalize: ^2.48.2
- orchestra/testbench: ^10.8
- pestphp/pest: ^4.1.6
- pestphp/pest-plugin-laravel: ^4.0
- pestphp/pest-plugin-type-coverage: ^4.0.3
- symfony/var-dumper: ^7.4.0
README
This library provides strongly-typed ID value objects for PHP 8.4+, designed to create type-safe entity identifiers with support for multiple ID generation strategies including UUID variants (v1, v3, v4, v5, v6, v7, v8), ULID, NanoID, GUID, Sqids, Hashids, Prefixed IDs (Stripe-style with configurable generators), Random String, and Random Bytes.
Requirements
Requires PHP 8.4+
Installation
composer require cline/strongly-typed-id
Documentation
- Getting Started - Installation and quick start
- Basic Usage - Creating and using IDs
- Laravel Integration - Eloquent casts and Data DTOs
- UUID Variants - UUID versions v1-v8
- ULID - Sortable identifiers
- NanoID - Compact URL-friendly IDs
- GUID - Windows/.NET compatibility
- Sqid - Short URL-safe identifiers
- Hashids - Obfuscated IDs with salt
- Prefixed IDs - Stripe-style prefixed identifiers
- Random String - Alphanumeric with Laravel's Str::random()
- Random Bytes - Hexadecimal with PHP's random_bytes()
- Advanced Patterns - DDD, CQRS, multi-tenancy
Change log
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.
Credits
License
The MIT License. Please see License File for more information.