PHPackages                             tenthfeet/laravel-sequence - 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. tenthfeet/laravel-sequence

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

tenthfeet/laravel-sequence
==========================

A flexible laravel package for generating sequential numbers with various patterns and reset policies.

v2.2.0(1mo ago)334MITPHPPHP ^8.2

Since Jul 27Pushed 1mo agoCompare

[ Source](https://github.com/tenthfeet/laravel-sequence)[ Packagist](https://packagist.org/packages/tenthfeet/laravel-sequence)[ Docs](https://github.com/tenthfeet/laravel-sequence)[ RSS](/packages/tenthfeet-laravel-sequence/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (11)Versions (7)Used By (0)

Laravel Sequence
================

[](#laravel-sequence)

A lightweight, flexible Laravel package for generating format-based sequential values with safe DB locking and reset policies.

Features
--------

[](#features)

- Concurrent-safe sequence generation with DB row locking
- Custom patterns: `{YYYY}`, `{MM}`, `{DD}`, `{H}`, `{M}`, `{S}`, `{SEQ}`, `{SEQ:N}`, `{FY}`
- Reset policies: `none`, `yearly`, `monthly`, `daily`, `financial_year`
- Model-scoped sequences (per record)
- Preview next value without incrementing

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

[](#installation)

Install via Composer:

```
composer require tenthfeet/laravel-sequence
```

Publish config and migration:

```
php artisan vendor:publish --provider="Tenthfeet\Sequence\SequenceServiceProvider" --tag="config"
php artisan vendor:publish --provider="Tenthfeet\Sequence\SequenceServiceProvider" --tag="migrations"
```

Run migrations:

```
php artisan migrate
```

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

[](#configuration)

Published config: `config/sequences.php`

```
return [
    'table' => 'sequences',
    'default_pattern' => '{SEQ:3}',
    'default_padding_character' => '0',
    'default_reset_policy' => \Tenthfeet\Sequence\Enums\ResetPolicy::None,
    'financial_year' => [
        'start_month' => \Carbon\Month::April,
    ],
];
```

Define a sequence
-----------------

[](#define-a-sequence)

Create a sequence definition:

```
php artisan make:sequence InvoiceSequence
```

Example class:

```
namespace App\Sequences;

use Tenthfeet\Sequence\SequenceDefinition;
use Tenthfeet\Sequence\Enums\ResetPolicy;

final class InvoiceSequence extends SequenceDefinition
{
    public function key(): string
    {
        return 'invoice';
    }

    public function __construct()
    {
        $this->pattern('INV-{YYYY}-{SEQ:4}')
            ->resetPolicy(ResetPolicy::Yearly);
    }
}
```

Generate sequences
------------------

[](#generate-sequences)

```
use Tenthfeet\Sequence\Sequence;
use App\Sequences\InvoiceSequence;

$sequence = new InvoiceSequence();
$value = Sequence::using($sequence)->next();
$preview = Sequence::using($sequence)->previewNext();
```

### Model-specific sequences

[](#model-specific-sequences)

```
use App\Sequences\ProjectTaskSequence;
use Tenthfeet\Sequence\Sequence;

$project = App\Models\Project::find(1);
$definition = (new ProjectTaskSequence())->forModel($project);
$value = Sequence::using($definition)->next();
```

### Runtime overrides

[](#runtime-overrides)

```
$definition = (new InvoiceSequence())
    ->pattern('INV-{YYYY}-{MM}-{SEQ:5}')
    ->padWith('0')
    ->resetPolicy(ResetPolicy::Monthly)
    ->financialYearStartsIn(\Carbon\Month::April)
    ->forModel($project)
    ->usingDate(now());
$value = Sequence::using($definition)->next();
```

#### Available fluent methods

[](#available-fluent-methods)

- `pattern(string $pattern)` - Set the sequence pattern
- `padWith(string $char)` - Set the padding character for sequence numbers
- `resetPolicy(ResetPolicy $policy)` - Set when the sequence should reset
- `financialYearStartsIn(Month $month)` - Set the financial year start month
- `forModel(Model $model)` - Scope the sequence to a specific model instance
- `usingDate(Carbon $date)` - Override the date used for date-based tokens

Pattern tokens
--------------

[](#pattern-tokens)

TokenOutput exampleDescription`{YYYY}`20264-digit year`{YY}`262-digit year`{MM}`03month`{DD}`16day`{H}`13hour`{M}`45minute`{S}`09second`{SEQ}`1counter raw`{SEQ:N}`0001padded counter`{FY}`2025-26financial year`{FY:YY-YY}`25-26financial year`{FY:YYYY-YY}`2025-26financial year`{FY:YYYY-YYYY}`2025-2026financial yearReset policies
--------------

[](#reset-policies)

```
use Tenthfeet\Sequence\Enums\ResetPolicy;

ResetPolicy::None;
ResetPolicy::Yearly;
ResetPolicy::Monthly;
ResetPolicy::Daily;
ResetPolicy::FinancialYear;
```

### Rollback sequences

[](#rollback-sequences)

```
use Tenthfeet\Sequence\Sequence;
use App\Sequences\InvoiceSequence;

$sequence = new InvoiceSequence();

// Rollback by 1 step (default)
Sequence::using($sequence)->rollback();

// Rollback by multiple steps
Sequence::using($sequence)->rollback(3);
```

Notes
-----

[](#notes)

Sequence rows are grouped by `key`, `reset_value`, and optional `model_type` / `model_id`.

License
-------

[](#license)

MIT

###  Health Score

43

—

FairBetter than 91% of packages

Maintenance89

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~48 days

Total

6

Last Release

55d ago

Major Versions

v1.0.1 → v2.0.02026-03-16

### Community

Maintainers

![](https://www.gravatar.com/avatar/af032b274982990a0429c5d5f74ba2dd3a18b0f6e7c95b6c4666237a5599e7e4?d=identicon)[Tenthfeet](/maintainers/Tenthfeet)

---

Top Contributors

[![perumalcodes](https://avatars.githubusercontent.com/u/97530388?v=4)](https://github.com/perumalcodes "perumalcodes (7 commits)")

---

Tags

laravelgeneratorsequenceserial numberauto-increment

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/tenthfeet-laravel-sequence/health.svg)

```
[![Health](https://phpackages.com/badges/tenthfeet-laravel-sequence/health.svg)](https://phpackages.com/packages/tenthfeet-laravel-sequence)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[spatie/laravel-enum

Laravel Enum support

3655.4M31](/packages/spatie-laravel-enum)[zonneplan/laravel-module-loader

Module loader for Laravel

24118.4k](/packages/zonneplan-laravel-module-loader)[tehwave/laravel-achievements

Simple, elegant Achievements the Laravel way

7012.8k](/packages/tehwave-laravel-achievements)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)

PHPackages © 2026

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