jeancodogno/doctrine-snowflake-id-bundle
Symfony bundle that integrates Snowflake ID generation with Doctrine ORM, giving entities time-sortable, distributed unique identifiers. Configure the generator and use Snowflake IDs as entity identifiers.
This is a Symfony bundle, not a Laravel package — that framing matters more than anything else on this page.
composer require jeancodogno/doctrine-snowflake-id-bundle, register the bundle in config/bundles.php, set doctrine_snowflake_id.datacenter_id and doctrine_snowflake_id.worker_id (almost always via env vars), then tag your entity/document ID property with the #[SnowflakeId] attribute. Drop the column's AUTO_INCREMENT/generatedValue strategy in the migration.laravel-doctrine/orm and register the bundle's listener + attribute driver manually, or (2) skip the bundle entirely and use godruoyi/php-snowflake inside an Eloquent creating observer. Path 2 is the sane default for a typical Laravel app.Where to look first in the source: the SnowflakeId attribute class, the Doctrine event listener (the only real logic), and the Configuration/Extension classes for the exact config keys and defaults.
First use case: replacing auto-increment IDs on a high-write table (orders, events, messages) where you want IDs generated in the app, sortable by time, and safe to produce without a DB round trip.
worker_id/datacenter_id must be unique per process (pod, container, host). Wire them from HOSTNAME, a K8s downward-API field, or an env var rendered at deploy time. Hardcoding 0 works in dev and corrupts you in prod.string in resources/serializers or JavaScript clients will silently round them (Number.MAX_SAFE_INTEGER).BIGINT UNSIGNED (or string if you're paranoid about JS/PHP interop). Remember to drop the AUTO_INCREMENT and any ->id() default from migrations.worker_id/datacenter_id in phpunit.xml so IDs are deterministic-ish and tests don't depend on deploy config. The 1.0.0 listener tests are a decent reference for asserting "ID was assigned and is non-null" without asserting exact values.postLoad/prePersist events through a small service provider and bind the config as a plain array — the bundle's autowiring won't happen for you.PHP_INT_MAX; on a 32-bit build you get float coercion and corrupted IDs.config/snowflake.php. Don't copy-paste Symfony docs into a Laravel app expecting it to work; budget a day for wiring or take the php-snowflake route.IdGenerator interface rather than calling the attribute everywhere. When you outgrow the bundle (or move off Doctrine), you swap one binding instead of touching every entity.doctrine.event_listener tag is the usual culprit, not the attribute itself.How can I help you explore Laravel packages today?