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

v4.0.2 2019-09-24 12:50 UTC

README

Latest Stable Version Build Status

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

Installation

You can install the package via Composer.

composer require robinvdvleuten/ulid

Usage

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

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

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

License

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