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(6mo ago)566.3k↓16.7%5MITPHPPHP ^8.2|^8.3|^8.4CI passing

Since Feb 28Pushed 6mo 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 1mo 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

48

—

FairBetter than 95% of packages

Maintenance67

Regular maintenance activity

Popularity37

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

195d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/efa9991a9ef5853517b380a3e06618f4b1d5a3b9fc2c4f42fe4d4b60373306fd?d=identicon)[omaressaouaf](/maintainers/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

[laragear/preload

Effortlessly make a Preload script for your Laravel application.

119363.5k](/packages/laragear-preload)[napp/xray-laravel

AWS X-Ray for Laravel applications.

61407.3k](/packages/napp-xray-laravel)[tapp/filament-google-autocomplete-field

Filament plugin that provides a Google Autocomplete field

3098.1k](/packages/tapp-filament-google-autocomplete-field)[tzookb/tbmsg

users messaging system

10917.1k](/packages/tzookb-tbmsg)[mindtwo/native-enum

Package for using native php enums.

2626.0k1](/packages/mindtwo-native-enum)[pyaesoneaung/laravel-myanmar-tools

A package for Myanmar tools which extend Laravel’s core.

291.4k](/packages/pyaesoneaung-laravel-myanmar-tools)

PHPackages © 2026

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