visus / cuid2
A PHP library for generating collision-resistant ids (CUIDs).
Installs: 636 388
Dependents: 3
Suggesters: 0
Security: 0
Stars: 36
Watchers: 3
Forks: 2
Open Issues: 0
Requires
- php: ^8.1
- markrogoyski/math-php: ^2.11
- symfony/polyfill-php83: ^1.32
Requires (Dev)
- ext-ctype: *
- captainhook/captainhook-phar: ^5.23
- captainhook/hook-installer: ^1.0
- ergebnis/composer-normalize: ^2.29
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^10.5
- ramsey/conventional-commits: ^1.5
- squizlabs/php_codesniffer: ^3.7
- vimeo/psalm: ^6.0
Suggests
- ext-gmp: Allows for quicker Base16 to Base36 conversion
README
A PHP implementation of collision-resistant ids. You can read more about CUIDs from the official project website.
Getting Started
You can install visus/cuid2 as a composer package:
composer require visus/cuid2
Tip
Consider installing/enabling the PHP extension GMP. If this is not an option then markrogoyski/math-php will be used as a fallback.
Quick Example
<?php require_once 'vendor/autoload.php'; // new (default length of 24) $cuid = new Visus\Cuid2\Cuid2(); // implicit casting echo $cuid; // apr5hhh4ox45krsg9gycbs9k // explicit casting echo $cuid->toString(); // apr5hhh4ox45krsg9gycbs9k // new (with custom length) $cuid = new Visus\Cuid2\Cuid2(10); echo $cuid; // pekw02xwsd