Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Sequence Bundle

Sequence Bundle Laravel Package

aboutcoders/sequence-bundle

Symfony bundle providing an abstract sequence implementation backed by Doctrine ORM. Register the bundle, set abc_sequence db_driver, then fetch the sequence manager service (abc.sequence.sequence_manager) to generate/manage sequences in your app.

View on GitHub
Deep Wiki
Context7

A symfony bundle that provides abstract sequence implementation

Frequently asked questions about Sequence Bundle
Can I use this bundle directly in Laravel, or is it strictly for Symfony?
While this is a Symfony bundle, you can integrate it into Laravel by wrapping it in a custom service provider. Register the bundle’s services in Laravel’s container, replace YAML config with Laravel’s `config/sequence.php`, and expose a facade (e.g., `Sequence::next('invoices')`) for cleaner usage. The core sequence logic remains reusable.
What Laravel versions does this bundle support?
This bundle doesn’t natively support Laravel, but you can adapt it to Laravel 8.x–10.x by creating a bridge layer for the Symfony container and configuring it via Laravel’s service provider. Test thoroughly, as Symfony’s DI container differs from Laravel’s. No official Laravel versioning is provided.
How do I configure custom sequence formats like 'INV-YYYY-MM-0001'?
The bundle supports custom formatting via the `db_driver` configuration (e.g., `orm`). Use Doctrine’s query builder or raw SQL to define the sequence logic, then format the output in your application code. For Redis or custom drivers, extend the bundle’s sequence abstraction to include formatting logic.
Will this work in distributed environments (e.g., multiple app servers)?
For distributed setups, use the Redis driver to avoid race conditions with database-backed sequences. The bundle supports multiple drivers, so configure `abc_sequence` with `redis` and ensure your Redis instance is clustered or sharded if needed. Database-backed sequences require transactions or `SELECT ... FOR UPDATE` to prevent conflicts.
How do I handle failures if the database or Redis is down?
The bundle doesn’t include built-in fallback logic, but you can wrap the sequence manager in a try-catch block and implement a fallback (e.g., file-based sequences or a static counter). For critical systems, consider a hybrid approach: use Redis for high availability and fall back to a local cache or database retry.
Does this bundle support UUIDv7 or other non-integer sequences?
The bundle is designed for integer-based sequences by default, but you can extend it to support UUIDv7 or other formats by customizing the driver logic. For UUIDv7, implement a custom driver that generates UUIDs with a timestamp component and integrates it into the sequence manager’s service container.
How do I integrate this with Laravel’s Eloquent models?
If using the ORM driver, you’ll need to bridge Doctrine to Eloquent. Create a custom Eloquent accessor (e.g., `$model->nextSequence()`) that calls the sequence manager via Laravel’s service container. Alternatively, use raw queries to fetch sequences from the database table managed by the bundle.
Are there performance concerns with database-backed sequences?
Database-backed sequences can become a bottleneck under high load (e.g., 10K+ ops/sec). Use Redis for distributed or high-throughput scenarios, or optimize the database driver with batch inserts or connection pooling. Test under load to identify contention points like `SELECT ... FOR UPDATE` locks.
What alternatives exist for Laravel if I don’t want to use a Symfony bundle?
For Laravel, consider native solutions like UUIDs (via `ramsey/uuid`), custom Eloquent accessors, or packages like `spatie/laravel-activitylog` for event-driven sequences. For Redis-backed sequences, use `predis/predis` directly or explore `spatie/laravel-redis-session-driver` for inspiration. Avoid reinventing the wheel unless you need Symfony-specific features.
How do I test this bundle in a Laravel application?
Mock the sequence manager in your tests using Laravel’s `Mockery` or PHPUnit’s `createMock()`. Test edge cases like concurrent requests, driver failures, and custom formatting. For database-backed sequences, use transactions to isolate tests and avoid race conditions. Example: `$sequenceManager = $this->app->make('sequence.manager');`
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware