Luminova Framework

PHP Luminova: Generate and Validate ULIDs

Last updated: 2026-11-28 20:57:12

Generate sortable, 26-character identifiers and check their format.

A Universally Unique Lexicographically Sortable Identifier (ULID) contains a millisecond timestamp and a random component encoded in Crockford Base32. Luminova increments the random component for successive calls within the same millisecond in the same process. The timestamp remains part of the identifier and can reveal its approximate creation time.


Usage

use Luminova\Utility\Ulid;

$id = Ulid::generate();
echo $id;
var_dump(Ulid::isValid($id, withTimestamp: true)); // bool(true)

Class Definition

  • Full namespace: Luminova\Utility\Ulid
  • This class is final.

Methods

generate

Generate a ULID using the current time and the framework’s monotonic random byte generator.

public static function generate(): string

Return:

string - An uppercase, 26-character ULID string.


isValid

Trim the input, convert it to uppercase, and verify the length and alphabet. With the timestamp check enabled, also check the decoded timestamp against a heuristic range from the Unix epoch to roughly 100 years ahead.

public static function isValid(string $ulid, bool $withTimestamp = false): bool

Parameters:

ParameterTypeDescription
$ulidstringCandidate identifier.
$withTimestampboolWhether to check the timestamp as well as the format (default: false).

Return:

bool - true if the selected checks pass.