PHPackages                             omaressaouaf/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. omaressaouaf/laravel-id-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

omaressaouaf/laravel-id-generator
=================================

Generate custom incremental unique ids for Laravel

1.3.0(8mo ago)577.3k↓65.3%5MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Feb 28Pushed 8mo ago2 watchersCompare

[ Source](https://github.com/omaressaouaf/laravel-id-generator)[ Packagist](https://packagist.org/packages/omaressaouaf/laravel-id-generator)[ Docs](https://github.com/omaressaouaf/laravel-id-generator)[ RSS](/packages/omaressaouaf-laravel-id-generator/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (4)Versions (6)Used By (0)

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

[](#laravel-id-generator)

[![Latest Stable Version](https://camo.githubusercontent.com/ac5457f3a9a9a9bf8a81f53f30887b2f1f6760dd954b11d52a823f255925d2af/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6f6d6172657373616f7561662f6c61726176656c2d69642d67656e657261746f722e737667)](https://packagist.org/packages/omaressaouaf/laravel-id-generator)[![License](https://camo.githubusercontent.com/dd9ad9999c4526476e07c37d63bd16c89c16aa218011db345bee8dc2fd3948de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f6d6172657373616f7561662f6c61726176656c2d69642d67656e657261746f72)](LICENSE)[![Tests](https://github.com/omaressaouaf/laravel-id-generator/actions/workflows/tests.yml/badge.svg)](https://github.com/omaressaouaf/laravel-id-generator/actions/workflows/tests.yml)

A Laravel package for generating **custom auto-incrementing IDs** with prefixes, suffixes, and date-based placeholders.

🚀 Features
----------

[](#-features)

- Auto-increment ID generation for any column.
- Allow custom prefixes &amp; suffixes &amp; padding
- Supports **{DATE}**, **{MONTH}**, and **{YEAR}** placeholders.

---

📥 Installation
--------------

[](#-installation)

Install via Composer:

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

---

📌 Usage
-------

[](#-usage)

### Basic Example

[](#basic-example)

Generate an ID with a **prefix and suffix and padding**:

```
use Omaressaouaf\LaravelIdGenerator\IdGenerator;
use App\Models\User;

$id = IdGenerator::generate(Invoice::class, 'column_name', 5, 'INV-', '-2024');

echo $id; // INV-00001-2024
```

### Dynamic Placeholders

[](#dynamic-placeholders)

- `{DATE}` → `2025-02-28`
- `{MONTH}` → `2025-02`
- `{YEAR}` → `2025`

```
$id = IdGenerator::generate(Invoice::class, 'column_name', 5, 'INV-{YEAR}-');
echo $id; // INV-2025-00001
```

### Initial starting point

[](#initial-starting-point)

Start from a specific number if there is no ID found in DB

```
$id = IdGenerator::generate(Invoice::class, 'column_name', 5, 'INV-', '', 5);
echo $id; // INV-2025-00005
```

### Generators

[](#generators)

After installation, you can publish the package configuration file using:

```
php artisan vendor:publish --provider="Omaressaouaf\LaravelIdGenerator\LaravelIdGeneratorServiceProvider"
```

This will create a configuration file in `config/laravel-id-generator.php`, allowing you define custom generators for different tables or models.

```
return [
    Invoice::class => [
        'field' => 'number',
        'padding' => 5,
        'prefix' => 'INV-',
        'suffix' => '-{YEAR}',
        'initial-starting-point' => 1
    ],
    'receipts' => [
        'field' => 'number',
        'padding' => 3,
        'prefix' => 'RC-',
    ]
];
```

Then you can use the generator

```
$id = IdGenerator::generateFromConfig(Invoice::class);
echo $id; // INV-00001-2025
```

---

🛠️ Testing
----------

[](#️-testing)

Run unit tests:

```
composer test
```

---

📜 License
---------

[](#-license)

This package is licensed under the [MIT License](https://github.com/omaressaouaf/laravel-id-generator/blob/master/LICENSE).

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance62

Regular maintenance activity

Popularity36

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~62 days

Total

5

Last Release

241d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/80538867?v=4)[Omar Essaouaf](/maintainers/omaressaouaf)[@omaressaouaf](https://github.com/omaressaouaf)

---

Top Contributors

[![omaressaouaf](https://avatars.githubusercontent.com/u/80538867?v=4)](https://github.com/omaressaouaf "omaressaouaf (73 commits)")[![rickzim](https://avatars.githubusercontent.com/u/72699017?v=4)](https://github.com/rickzim "rickzim (1 commits)")[![webard](https://avatars.githubusercontent.com/u/855788?v=4)](https://github.com/webard "webard (1 commits)")

---

Tags

id-generationid-generatorincrement-idlaravellaravel-id-generatorphpphplaravelid-generatoromaressaouaflaravel-id-generatorid-generationincrement-id

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/omaressaouaf-laravel-id-generator/health.svg)

```
[![Health](https://phpackages.com/badges/omaressaouaf-laravel-id-generator/health.svg)](https://phpackages.com/packages/omaressaouaf-laravel-id-generator)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[tapp/filament-google-autocomplete-field

Filament plugin that provides a Google Autocomplete field

30136.4k](/packages/tapp-filament-google-autocomplete-field)[tomshaw/electricgrid

A feature-rich Livewire package designed for projects that require dynamic, interactive data tables.

119.4k](/packages/tomshaw-electricgrid)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
