Persistent sequences

0.5.0 2021-08-29 14:45 UTC

This package is auto-updated.

Last update: 2021-12-29 15:27:05 UTC


Latest Version Software License PHP Version Total Downloads

Supports custom number generation by user-defined algorithms.


composer require sbooker/persistent-sequences 


Step 1. Define Sequence mapping to persistent storage

Step 2. Define you custom sequence calculation algorithm. For example:

class ConcreteAlgorithm implements \Sbooker\PersistentSequences\Algorithm
    public function first(): string
        // return first item in sequence
    public function next(string $currentValue): string 
        // return next item in sequence

Step 3. Define you sequence write storage or use Doctrine implementation

class ConcreteWriteStorage implements \Sbooker\PersistentSequences\SequenceWriteStorage

Step 4. Configure SequenceGenerator

$sequenceGenerator =
    new \Sbooker\PersistentSequences\SequenceGenerator(
        new ConcreteWriteStorage(),
        new \Sbooker\TransactionManager\TransactionManager(
            // see sbooker/transaction-manager

Step 5. Use SequenceGenerator to generate sequence

$number = $sequenceGenerator->next('concrete-seq', new ConcreteAlgorithm());


See LICENSE file.