PHPackages                             danfekete/sequential - 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. danfekete/sequential

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

danfekete/sequential
====================

Sequential ID generator

0.3.2(9y ago)013MITPHPPHP &gt;=5.6

Since Aug 15Pushed 9y ago1 watchersCompare

[ Source](https://github.com/danfekete/Sequential)[ Packagist](https://packagist.org/packages/danfekete/sequential)[ RSS](/packages/danfekete-sequential/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (7)Used By (0)

Sequential
==========

[](#sequential)

This library is the successor of the SeqDB engine. The whole purpose of this library is to enable the generation of truly sequential IDs into buckets even when running parallel.

There are times when you need to make sure that when sequentially generating the IDs there are no gaps or repetitions.

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

[](#installation)

```
$ composer require danfekete/sequential

```

Usage
-----

[](#usage)

### Framework agnostic

[](#framework-agnostic)

You don't need an underlying framework to use this library.

```
$data = new SQLite();
$seq = new Sequential($data);
$bucket = new Bucket($userID);
$nextID = $seq->generate($bucket);
```

### With Laravel 5.2+

[](#with-laravel-52)

After installing with composer run

```
$ php artisan vendor:publish --provider=danfekete\Sequential\SequentialServiceProvider

```

After this, you should see the `sequential.php` in your `config` directory. Make the neccessary adjustments (however it also works out of the box).

In your `config/app.php` add the following:

```
'providers' => [
  // ...
  danfekete\Sequential\SequentialServiceProvider::class,
  // ...
];

'aliases' => [
  // ...
  'Sequential' =>  danfekete\Sequential\SequentialFacade::class,
  // ...
];
```

To generate an ID:

```
$bucket = new Bucket($userID);
$nextID = Sequential::generate($bucket);
```

### Configuration

[](#configuration)

When using Laravel, the configuration is done in the `sequential.php` file, otherwise it is done in the constructor.

- `dataProvider` *(in constructor)* - the data object that implements the `DataProdvider` interface, more on data providers later
- `data_provider_class` *(in laravel config)* - the fully qualified name of the class that implements the `DataProvider` interface
- `sharedMutex` - if `true`, then the mutex is shared with every bucket, meaning that only a single ID generation takes place at each given moment regardless of the bucket. Otherwise every bucket can run ID generation simultaneously which is the default behaviour.
- `incrementBy` - the amount to increment by when generating a new ID

### Data providers

[](#data-providers)

The data providers implement the `DataProvider` interface. The interface has three methods that must be implemented:

- `getLastID(Bucket $bucket)` - returns the last ID generated for the given bucket
- `store(Bucket $bucket, $value)` - store the value for the bucket
- `reset(Bucket $bucket)` - reset the bucket value to `0`

You can use the default SQLite data provider or you can roll your own with any kind of advanced of logic. Buckets can contain any amount of data that can be used to query the last ID.

Distributed use
---------------

[](#distributed-use)

One of the hardest part of sequential ID generation is distributed use. To enable this, there is a specialized version of the main class called `DistributedSequential` which uses the RedLock DLM algorithm from Redis. You'll need one more Redis servers to use and also the Predis library.

```
$c1 = new Predis\Client('tcp://10.0.0.1:6379');
$c2 = new Predis\Client('tcp://10.0.0.2:6379');
$data = new SQLite();
$seq = new DistributedSequential([$c1, $c2], $data);
$bucket = new Bucket($userID);
$nextID = $seq->generate($bucket);
```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

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 ~18 days

Total

5

Last Release

3533d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/44952ac11bee81804ffd10caecf0e48b8bdba1161efade40a781232b1641aa13?d=identicon)[danfekete](/maintainers/danfekete)

### Embed Badge

![Health badge](/badges/danfekete-sequential/health.svg)

```
[![Health](https://phpackages.com/badges/danfekete-sequential/health.svg)](https://phpackages.com/packages/danfekete-sequential)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M341](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[illuminate/pagination

The Illuminate Pagination package.

12234.1M1.0k](/packages/illuminate-pagination)[illuminate/pipeline

The Illuminate Pipeline package.

9349.2M275](/packages/illuminate-pipeline)[flarum/core

Delightfully simple forum software.

201.4M2.3k](/packages/flarum-core)[illuminate/redis

The Illuminate Redis package.

9014.6M367](/packages/illuminate-redis)

PHPackages © 2026

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