A simple and robust implementation of ULID in PHP

v1.0.0 2021-12-18 16:31 UTC

This package is not auto-updated.

Last update: 2024-11-18 05:04:08 UTC


README

codecov CI Status Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

A simple and robust implementation of ULID in PHP with no dependency.

Works on its own, but utilizes Ramsey\Uuid\Uuid if present.

Installation

$ composer require yu-ichiro/ulid

Usage

use Ulid\Ulid

new Ulid();  // ULID {01FQ75VPEBGY1JZSRD03EMM5QM}
new Ulid('01FQ75VPEBGY1JZSRD03EMM5QM');  // ULID {01FQ75VPEBGY1JZSRD03EMM5QM}
new Ulid('017dce5d-d9cb-8783-2fe7-0d00dd4a16f4');  // ULID {01FQ75VPEBGY1JZSRD03EMM5QM}

(string) new Ulid(); // "01FQ75VPEBGY1JZSRD03EMM5QM"
(new Ulid())->jsonSerialize(); // "01FQ75VPEBGY1JZSRD03EMM5QM"
(new Ulid())->toUuid(); // "017dce5d-d9cb-8783-2fe7-0d00dd4a16f4"