PHPackages                             devaspid/laravel-id-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. devaspid/laravel-id-generator

ActiveLibrary[Database &amp; ORM](/categories/database)

devaspid/laravel-id-generator
=============================

Concurrency-safe document and identifier number generation for Laravel.

1.0.1(1mo ago)161MITPHPPHP ^8.3

Since Jul 11Pushed 1mo agoCompare

[ Source](https://github.com/dev-asp-id/laravel-id-generator)[ Packagist](https://packagist.org/packages/devaspid/laravel-id-generator)[ RSS](/packages/devaspid-laravel-id-generator/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (6)Versions (3)Used By (0)

Laravel ID Generator
====================

[](#laravel-id-generator)

Generate business document numbers such as invoices, transactions, procurement records, and purchase orders without scanning their transaction tables.

The package keeps only mutable counter state in `id_sequences`; formatting and reset behaviour remain version-controlled in `config/id-generator.php`. Counters are incremented inside a database transaction with a row lock, making the generator safe for concurrent requests.

Try Demo
========

[](#try-demo)

[Click](http://opensource.asp.web.id/demo-laravel-id-generator)

Features
--------

[](#features)

- Laravel 12 and 13 support, PHP 8.3+
- One compact state row per configured generator
- Atomic, concurrency-safe sequence increments
- Global, yearly, monthly, and daily scopes
- Prefix, suffix, left padding, and date placeholders
- `id-generator:sync` command to create missing sequence rows
- No scheduler and no lookup of invoice/transaction tables

Requirements
------------

[](#requirements)

- PHP 8.3 or newer
- Laravel 12 or Laravel 13
- A database connection that supports transactions and row locks in production

Installation
------------

[](#installation)

Install the package:

```
composer require devaspid/laravel-id-generator
```

Publish its configuration and migration, then migrate:

```
php artisan vendor:publish --tag=id-generator-config
php artisan vendor:publish --tag=id-generator-migrations
php artisan migrate
```

Define your generators in `config/id-generator.php`, then create their state rows:

```
php artisan id-generator:sync
```

Run `id-generator:sync` on every environment after adding a generator. It creates missing rows only; it never resets or overwrites an existing counter.

Configuration
-------------

[](#configuration)

```
