UUID (RFC 9562), ULID, Snowflake ID, Sonyflake ID, and TBSL generator for PHP.

Maintainers

Package info

github.com/infocyph/UID

pkg:composer/infocyph/uid

Statistics

Installs: 5 534

Dependents: 0

Suggesters: 0

Stars: 11

Open Issues: 0

4.2 2026-05-14 16:22 UTC

This package is auto-updated.

Last update: 2026-05-14 16:24:32 UTC


README

Security & Standards Documentation Packagist Downloads License: MIT Packagist Version Packagist PHP Version GitHub Code Size

All-in-one unique ID toolkit for PHP.

Features

  • UUID (v1, v3, v4, v5, v6, v7, v8)
  • ULID (monotonic and random modes)
  • Snowflake, Sonyflake, TBSL
  • Randflake (encrypted 64-bit IDs with lease-bound node windows)
  • NanoID, CUID2, KSUID, XID
  • Opaque and deterministic IDs
  • Value objects and comparator utilities
  • Binary conversion and base encoders (16, 32, 36, 58, 62)
  • Pluggable sequence providers (filesystem, memory, PSR-16 cache, callback)

Requirements

  • PHP >=8.2
  • ext-bcmath

Installation

composer require infocyph/uid

Global helper functions are autoloaded via src/functions.php.

Quick Usage

<?php

use Infocyph\UID\Id;
use Infocyph\UID\CUID2;
use Infocyph\UID\NanoID;

$uuid = Id::uuid();      // default UUID strategy (v7)
$ulid = Id::ulid();
$snowflake = Id::snowflake();
$sonyflake = Id::sonyflake();
$tbsl = Id::tbsl();
$randflake = \Infocyph\UID\Randflake::generate(
    nodeId: 42,
    leaseStart: time() - 5,
    leaseEnd: time() + 300,
    secret: 'super-secret-key',
);
$nanoid = NanoID::generate(21);
$cuid2 = CUID2::generate(24);
<?php

use Infocyph\UID\UUID;

$uuid = UUID::v7();
$ok = UUID::isValid($uuid);
$parsed = UUID::parse($uuid);

$bytes = UUID::toBytes($uuid);
$roundTrip = UUID::fromBytes($bytes);

$base58 = UUID::toBase($uuid, 58);
$decoded = UUID::fromBase($base58, 58);

The shared byte-level encoder is available as Infocyph\UID\Support\BaseEncoder for bases 16, 32, 36, 58, and 62.

References