Upgrade
Added
- Merged the Laravel integration (previously the standalone
bradietilley/laravel-snowflakepackage) into this package under theBradieTilley\Snowflake\Laravel\namespace. HasSnowflakeEloquent trait for automatically assigning Snowflake IDs to models.SnowflakeServiceProvider(auto-discovered) and a publishablesnowflakeconfig file.LaravelSequenceResolverfor cache-based concurrency (atomicadd+increment, no lock), andSequentialIdentifierResolverfor predictable sequential IDs in tests.Snowflake::reset()to clear all static configuration and resolvers, primarily to avoid global state leaking between tests.Snowflake::configureSignature($workerIdBits, $clusterIdBits)to trade cluster/worker capacity for sequence bits (sequence bits are derived; minimum 3). The signature freezes after the first generated ID.
Changed
- The Laravel integration is fully opt-in. The core Snowflake generator has no framework dependency;
illuminate/*packages are declared assuggestand dev-only requirements, so non-Laravel consumers are unaffected. - The Laravel integration targets Laravel 13 (
^13.0). This is developed and tested againstorchestra/testbench: ^11.0. - README now documents both standalone and Laravel usage in a single place.
- Default sequence resolver is now
MemorySequenceResolver(wasFileSequenceResolver). Opt into file or cache coordination explicitly. - Laravel
snowflake.sequencing.resolverdefaults tonull(memory). Set it toLaravelSequenceResolver::class(or another resolver) to auto-register on boot.
Fixed
- The Laravel cache-based sequence resolver is registered when configured. The previous
laravel-snowflakepackage definedsnowflake.sequencing.resolverbut never wired it intoSnowflake::sequenceResolver(). TheSnowflakeGeneratornow reads that config value and registers the resolver via the container when set. LaravelSequenceResolverno longer takes a global cache lock on every ID; it uses atomicadd+incrementper microsecond key.- Resolved a PHPStan (max level) error in
SequentialIdentifierResolver::identifier()where a nullable$groupwas used as an array key.
Breaking Changes
- Users of the old
bradietilley/laravel-snowflakepackage must update namespaces fromBradieTilley\Snowflakes\...toBradieTilley\Snowflake\Laravel\.... For example,BradieTilley\Snowflakes\Eloquent\HasSnowflakebecomesBradieTilley\Snowflake\Laravel\Eloquent\HasSnowflake. - The service provider was renamed from
BradieTilley\Snowflakes\SnowflakesServiceProvidertoBradieTilley\Snowflake\Laravel\SnowflakeServiceProvider. Auto-discovery handles this automatically; only manual provider registrations need updating. - The Laravel integration now requires Laravel 13 (
^13.0). Laravel 11 and 12 are no longer supported. Thebradietilley/laravel-snowflakev1.x line remains available for Laravel 11/12 projects. - Default sequence resolver is in-memory, not file-based. Multi-process apps sharing a worker id must call
Snowflake::sequenceResolver(...)or set Laravelsequencing.resolver. - Laravel no longer enables
LaravelSequenceResolverby default; setsnowflake.sequencing.resolverexplicitly. - Runtime bit widths are no longer read from
Snowflake::WORKER_ID_BITS/CLUSTER_ID_BITS/SEQUENCE_BITS/MAX_SEQUENCEconstants — useconfigureSignature()and theworkerIdBits()/clusterIdBits()/sequenceBits()/maxSequence()getters.