Universally Unique Lexicographically Sortable Identifier (ULID) implementation for PHP.

v5.0.0 2020-12-06 19:13 UTC

This package is auto-updated.

Last update: 2024-03-23 12:07:11 UTC


Latest Stable Version Build Status

A PHP port of ulid/javascript with some minor improvements.

Sponsored by The Webstronauts


You can install the package via Composer.

composer require robinvdvleuten/ulid


use Ulid\Ulid;

$ulid = Ulid::generate();
echo (string) $ulid; // 01B8KYR6G8BC61CE8R6K2T16HY

// Or if you prefer a lowercased output
$ulid = Ulid::generate(true);
echo (string) $ulid; // 01b8kyr6g8bc61ce8r6k2t16hy

// If you need the timestamp from an ULID instance
$ulid = Ulid::generate();
echo $ulid->toTimestamp(); // 1561622862

// You can also generate a ULID for a specific UNIX-time in milliseconds
$ulid = Ulid::fromTimestamp(1593048767015);
// or with a lower cased output: $ulid = Ulid::fromTimestamp(1593048767015, true);
echo (string) $ulid; // 01EBMHP6H7TT1Q4B7CA018K5MQ


composer test


Please see the GitHub "Releases" page for more information on what has changed recently.


As it's just a simple port of JavaScript to PHP code. All credits should go to the original ULID specs.


The MIT License (MIT). Please see License File for more information.