calicastle / cuid
A CUID generator
Installs: 12 510
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.2|^8.0
README
A CUID (Collision Resistant Unique Identifier) is a method of creating a unique identifier that was developed by Eric Elliott. The purpose is to create unique IDs for use in web applications to better support horizontal scaling and sequential lookup performance.
Install
composer require calicastle/cuid
Example Usages
use CaliCastle\Cuid; Cuid::make(); // ckbe1q3gi000001jsfnm9cm81 Cuid::make('u'); // ukbe1qos1000201js74bwas75
Laravel Eloquent
use CaliCastle\Concerns\HasCuid; // Each user will have an id of something // like "ukbe1q3gi000001jsfnm9cm81" class User extends Model { use HasCuid; /** * Get the CUID prefix. */ public static function getCuidPrefix(): string { return 'u'; } }