Download the PHP package dejodev/laravel-sequence-number-generator without Composer
On this page you can find all versions of the php package dejodev/laravel-sequence-number-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download dejodev/laravel-sequence-number-generator
More information about dejodev/laravel-sequence-number-generator
Files in dejodev/laravel-sequence-number-generator
Package laravel-sequence-number-generator
Short Description Generate complex sequencenumbers using DB locking to ensure each number is unique
License MIT
Homepage https://github.com/dejodev/laravel-sequence-number-generator
Informations about the package laravel-sequence-number-generator
Generate complex sequence numbers using DB locking to ensure each number is unique.
This package allows you to generate complex sequence numbers in Laravel applications. It uses database locking to ensure that each generated number is unique, even in high-concurrency environments. You can configure different sequence types, masks, and yearly resets to suit your application's needs.
Features
- Generate unique sequence numbers using database locking
- Support for custom sequence types
- Configurable sequence masks
- Yearly resets for sequences
- High-concurrency environment support
- Easy configuration via environment variables
- Simple integration with Laravel applications
Basic Usage
To generate a sequence number, you can use the facade provided by the package:
Warning This package uses database locking to ensure that each generated number is unique so you must use a database that supports lockForUpdate() like MySQL, MariaDB or PostgreSQL.
Installation and usage
You can install the package via Composer:
Then publish run the migrations with:
Set the environment variables in your .env
file:
Environment Variables
SEQUENCE_NUMBER_GENERATOR_DEFAULT
: The default sequence configuration to use. Default isdefault
.SEQUENCE_NUMBER_GENERATOR_TYPE
: The type for the default generator. Type is a string value that distinguishes between different sequence generators. Default isdefault
.SEQUENCE_NUMBER_GENERATOR_MASK
: The mask format string for the default generator. Default is{#}
.SEQUENCE_NUMBER_GENERATOR_IS_YEARLY
: Boolean to determine if the default generator should reset yearly. Default isfalse
.
Mask Variables
The mask format string can contain the following variables:
{####}
: The sequential number with leading zeros. The number of#
characters determines the length of the padding.{Y}
: The full year (e.g., 2025).{y}
: The last two digits of the year (e.g., 25).{T}
: The sequence type.{t}
: First letter of the sequence type.
You can also publish the config file with:
Using the config file, you can define multiple sequence configurations for your application.
Then use them like this:
Advanced Usage
you can also use the SequenceNumberGenerator
class directly to generate sequence numbers without using the facade.
Check out SequenceNumberGenerator.php
for more advanced usage and customization options.
(c) The MIT License (MIT). Please see License File for more information.
All versions of laravel-sequence-number-generator with dependencies
carbon-cli/carbon-cli Version ^1.3
illuminate/contracts Version ^10.0||^11.0||^12.0
spatie/laravel-package-tools Version ^1.16