https://github.com/visus-io/php-cuid2
PHP implementation of collision-resistant ids
https://github.com/visus-io/php-cuid2
cuid cuid-generator php
Last synced: 9 months ago
JSON representation
PHP implementation of collision-resistant ids
- Host: GitHub
- URL: https://github.com/visus-io/php-cuid2
- Owner: visus-io
- License: mit
- Created: 2023-01-13T20:11:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-10T19:37:54.000Z (over 1 year ago)
- Last Synced: 2025-03-29T22:05:43.897Z (about 1 year ago)
- Topics: cuid, cuid-generator, php
- Language: PHP
- Homepage:
- Size: 435 KB
- Stars: 31
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# visus/cuid2
[](https://github.com/visus-io/php-cuid2/actions/workflows/ci.yaml)
[](https://sonarcloud.io/summary/overall?id=visus%3Aphp-cuid2)
[](https://sonarcloud.io/summary/overall?id=visus%3Aphp-cuid2)
[](https://sonarcloud.io/summary/overall?id=visus%3Aphp-cuid2)

[](https://packagist.org/packages/visus/cuid2)


A PHP implementation of collision-resistant ids. You can read more about CUIDs from the [official project website](https://github.com/paralleldrive/cuid2).
## Getting Started
You can install visus/cuid2 as a [composer package](https://packagist.org/packages/visus/cuid2):
```shell
composer require visus/cuid2
```
> [!TIP]
> Consider installing/enabling the PHP extension [GMP](https://www.php.net/manual/en/intro.gmp.php).
> If this is not an option then [markrogoyski/math-php](https://github.com/markrogoyski/math-php) will be used as a fallback.
## Quick Example
```php
toString(); // apr5hhh4ox45krsg9gycbs9k
// new (with custom length)
$cuid = new Visus\Cuid2\Cuid2(10);
echo $cuid; // pekw02xwsd
```