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

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

griffins/sequence
=================

A simple sequence generator

1.0.1(8y ago)01.2kMITPHP

Since Jul 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/griffins/sequence)[ Packagist](https://packagist.org/packages/griffins/sequence)[ RSS](/packages/griffins-sequence/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

sequence
========

[](#sequence)

A simple sequence generator

[![Build Status](https://camo.githubusercontent.com/8af999253a289efb03573be69b56d92ccf872c8b7572ee0991c795e37096f948/68747470733a2f2f6170692e7472617669732d63692e6f72672f6772696666696e732f73657175656e63652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/griffins/sequence)

installation
============

[](#installation)

`composer require griffins/sequence`

basics
======

[](#basics)

This doc assumes you are autoloading the library via composer.

```

$allowedChars = 'ABCDEF0123456789';
//the only argument is an optional character dictonary, if not specified the default one is used. (0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ)
$sequence = \Sequence\Factory::create($allowedChars);

echo $sequence->next('/????');
```

Prints `2018/0001`

`, , ` are place holders for the current year,month and day respectively.

```
$sequence->next('/????',null,'2018/AAAA')
```

Prints `2018/AAAB`

The second argument is a callback that returns true or false to reject the generated sequence, when its returns false it causes a new sequence to be generated till the callback is satisfied or an overflow occours. For example trying to increment 9999 and the format used is limited to 4 characters.

The smart search optimizes usage of the callback by using binary search to boost perfomance.

A good usage will be

```
$sequence = \Sequence\Factory::create();

$id =  $sequence->next('/????', function($id){
    //check if its exits in a dataset,

    if($exists){
        return true;
    }else{
        // looks like we found a valid id
        return false;
    }
});
// now use the id generated

echo $id;
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Total

2

Last Release

3025d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/804be512c159d08f2bbe42a296918bd04bb2c30014b8bfdb7018bf2e1974b29f?d=identicon)[griffins](/maintainers/griffins)

---

Top Contributors

[![griffins](https://avatars.githubusercontent.com/u/4579591?v=4)](https://github.com/griffins "griffins (6 commits)")

---

Tags

generatornumber-formatphpsequence

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

PHPackages © 2026

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