Pure PHP, zero deps
No extensions or external services; all 64-bit integer math runs in PHP.
Snowflake / PHP + Rust
Timestamp, datacenter, worker and sequence in one integer. No database, no coordinator.
Snowflake packs the current millisecond, datacenter, worker and a 12-bit sequence into one 64-bit integer; id() runs entirely in-process.
The core is a single stateful class, paired with one shared config file and a PSR-11 factory, so plain PHP and six frameworks share the same call.
A blue and white snowflake sprite with six arms around a round smiling face, scattered starlight and falling snow.
Every millisecond, one ordered ID.Generation, clock drift handling and reverse parsing all live in the same class.
No extensions or external services; all 64-bit integer math runs in PHP.
Timestamp, datacenter, worker and sequence bits can be reordered to fit your scale.
Sequential, random-start and Redis-backed counters, plus a custom resolver interface.
Set a tolerance window, then wait for the wall clock or throw when it is exceeded.
parseId splits an ID back into timestamp, datacenter, worker and sequence.
Laravel, Webman, ThinkPHP, Hyperf, Yii2 and Yii3 share the same core.
Beyond the PHP package, a pure std Rust implementation is available with zero dependencies.
Snowflake IDs for Rust
64-bit IDs, adjustable bits, three sequence modes and clock drift handling, zero dependencies.
Every entry maps to a real release.
Twelve ASCII mascot forms land in the Mascot class for terminals; adds a 1280x640 social preview image.
Redraws twelve animated SVG expressions with a unified look, palette and motion.
Aligns READMEs and diagrams in 11 languages with the current English version, fixing several claim drifts.
Adds PHPStan level 8, a PSR-11 factory, the Redis sequence strategy and a waitable clock drift path.
Click an image to enlarge.
Install first, then run a minimal example.
composer require erikwang2013/snowflake-phpuse Erikwang2013\Snowflake\Snowflake;
$snowflake = new Snowflake(workerId: 5, datacenterId: 3);
$id = $snowflake->id();
$parsed = $snowflake->parseId($id);
echo $id;cargo add snowflake-id-rustuse snowflake::Snowflake;
let mut snowflake = Snowflake::default();
let id = snowflake.id()?;
println!("{id}");Hover for a moment and it changes expression.