PHPackages                             segfaultinc/finite - 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. segfaultinc/finite

AbandonedArchivedLibrary

segfaultinc/finite
==================

Simple yet powerful Finite State Machine implementation

1.1.0(6y ago)227.1k[1 issues](https://github.com/segfaultinc/finite/issues)MITPHPPHP ^7.2

Since Aug 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/segfaultinc/finite)[ Packagist](https://packagist.org/packages/segfaultinc/finite)[ Docs](https://github.com/segfaultinc/finite)[ RSS](/packages/segfaultinc-finite/feed)WikiDiscussions master Synced yesterday

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

WORK IN PROGRESS
================

[](#work-in-progress)

---

Usage
-----

[](#usage)

```
$order = new Order(); // see below
$graph = new Graph(); // see below

$graph->apply($order, 'transition-input');
```

```
use SegfaultInc\Finite\Subject;

class Order extends Model implements Subject
{
    public function setFiniteState($state)
    {
        $this->update([
            'status' => $state,
        ]);
    }

    public function getFiniteState($state)
    {
        return $this->status;
    }
}
```

Graph definition
----------------

[](#graph-definition)

```
(new Graph)
    ->setStates([

        State::initial('new')
            ->label('New')
            ->leaving(function (Order $order) {
                // This is executed every time the `in_progress` is **transitioned from**.
                // Useful if you want to do something that is "state" dependent

                $order->update([
                    'started_at' => now()
                ]);
            }),

        State::normal('in_progress')
            ->label('In Progress'),

        State::final('finished')
            ->label('Finised'),

        State::final('canceled')
            ->label('Canceled')
            ->entering(function (Order $order) {
                // If you transition to "canceled" state from multiple states,
                // this is the place to perform the common logic
            }),

    ])
    ->setTransitions([

        Transition::make('new', 'in_progress', 'progress')
            ->pre(function (Order $order) {
                if ($order->validate()) {
                    throw new OrderValidationException('When an exception is thrown in "pre" hook, the transition is not applied');
                }
            }),

        Transition::make('in_progress', 'finished', 'progress'),

        Transition::make('in_progress', 'canceled', 'cancel')
            ->post(function (Order $order) {
                $order->user->notify(new YourOrderWasCanceled);
            }),

    ]);
```

Visualization
-------------

[](#visualization)

```
$graph->visualize()

// uses GraphViz under the hood
```

[![](https://user-images.githubusercontent.com/4470539/53287565-e4bfff00-3775-11e9-9aea-8b498ba5ac09.png)](https://user-images.githubusercontent.com/4470539/53287565-e4bfff00-3775-11e9-9aea-8b498ba5ac09.png)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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

Total

2

Last Release

2404d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/607fdbadbf1592de1540083713c2777732a595314ef59f2d921b748f8bfe2770?d=identicon)[jerguslejko](/maintainers/jerguslejko)

---

Top Contributors

[![jerguslejko](https://avatars.githubusercontent.com/u/4470539?v=4)](https://github.com/jerguslejko "jerguslejko (65 commits)")

---

Tags

finite-state-machinefinitesegfaultinc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/segfaultinc-finite/health.svg)

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

###  Alternatives

[hellogerard/jobby

Manage all your cron jobs without modifying crontab. Handles locking, logging, error emails, and more.

1.1k1.6M14](/packages/hellogerard-jobby)[rolfvreijdenberger/izzum-statemachine

A superior statemachine library php &gt;= 5.3. Integrates with your domain models perfectly.

7425.5k](/packages/rolfvreijdenberger-izzum-statemachine)[gomachan46/state-machine

simple state machine with annotations for PHP, inspired by AASM known as a Ruby state machine.

1893.9k](/packages/gomachan46-state-machine)[kendall-hopkins/formal-theory

FormalTheory is a library that allows for manipulation and conversion of NFAs, DFAs and Regular Expressions.

335.4k](/packages/kendall-hopkins-formal-theory)[weblabormx/laravel-front

Front is a administration panel for Laravel. It allows you to create CRUD easily in minutes. It allows to fully customize any part of the code.

1111.1k](/packages/weblabormx-laravel-front)[infocyph/intermix

A Collection of useful PHP class functions.

136.4k1](/packages/infocyph-intermix)

PHPackages © 2026

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