webpatser/ulid is a pure PHP library to generate and validate ULIDs (Universally Unique Lexicographically Sortable Identifiers). IDs are Crockford Base32 encoded and monotonic, with UUID interop through webpatser/uuid, the sibling library.
composer require webpatser/ulid
Requirements
- PHP
^8.6. No extensions are required. webpatser/uuid^3.0, installed automatically by Composer.
Note: The package supports only the latest stable PHP release. When a new PHP version is released, the next release of this package requires it and support for the previous PHP version ends. Currently that is PHP 8.6. On PHP 8.5, stay on 2.x.
Verify the install
use Webpatser\Ulid\Ulid; echo (string) Ulid::generate(); // 26 characters, e.g. 01ARZ3NDEKTSV4RRFFQ69G5FAV
Next: Quick start.