PHPackages                             markusbiggus/stateengine - 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. markusbiggus/stateengine

ActiveLibrary

markusbiggus/stateengine
========================

Finite state automata engine

00PHP

Since Jul 29Pushed 1y ago1 watchersCompare

[ Source](https://github.com/MarkusBiggus/StateEngine)[ Packagist](https://packagist.org/packages/markusbiggus/stateengine)[ RSS](/packages/markusbiggus-stateengine/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)Used By (0)

stateengine
===========

[](#stateengine)

Finite State Automata for Laravel/PHP Framework

Overview
--------

[](#overview)

This package is a State Engine that executes workflows based on a state model. Essentially, a finite state automata.

It can work in a similar way to Laravel pipeline if each step in the pipeline is a state with at most one defined transition to the next state(s). Imagine the pipeline twisted into a knot with splits and joins for fully dynamic logic flow.

The StateEngine allows multiple possible transitions from each state to one or more states, according to a state model. Each State is a class object that has the responsibility for executing the state logic and choosing which transition to emit when done. A state may be executed more than once, until it emits a transition. The engine dispatch cycle runs each state in according to the transitions they emit until the Terminal state is executed. Two dispatch cycles with no transition emitted or state changes will stall the workflow with a Runtime Exception.

If all states in a model have only a single transition choice, the state does not need to emit the transition, it will behave like a pipeline. The 'Split' transition allows a pipeline to branch multiple paths, each a pipeline running in parallel. A state with no transition choice will end a path.

A reference model is included to demonstrate how the state model is implemented.

[![Reference model (pdf)](https://github.com/MarkusBiggus/StateEngine/raw/7cdbb9c38f23b9268b1436b4fb7705391e19d9d5/StateEngine-ReferenceModel.pdf)](https://github.com/MarkusBiggus/StateEngine/blob/7cdbb9c38f23b9268b1436b4fb7705391e19d9d5/StateEngine-ReferenceModel.pdf)

### Tests

[](#tests)

There are tests using the reference model to demonstrate the a Workflow with several different paths through the model. Additional tests demonstrate other aspects of combining special transitions as well as how the Engine can fail when transitions are not emitted as required.

[![Test models (pdf)](https://github.com/MarkusBiggus/StateEngine/raw/7cdbb9c38f23b9268b1436b4fb7705391e19d9d5/StateEngine-Test-Models.pdf)](https://github.com/MarkusBiggus/StateEngine/blob/7cdbb9c38f23b9268b1436b4fb7705391e19d9d5/StateEngine-Test-Models.pdf)

### Installation

[](#installation)

Use Composer to install the package and all necessary dependencies.

```
composer require markusbiggus/stateengine

```

### Running tests

[](#running-tests)

Publish tests before running.

```
 php artisan vendor:publish --provider="MarkusBiggus\StateEngine\StateEngineProvider"
 php artisan test

```

MIT License
-----------

[](#mit-license)

Copyright (c) 2024 Mark Charles

stateengine is open-source software, licensed under the \[MIT license\] (LICENSE.md).

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance28

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 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.

### Community

Maintainers

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

---

Top Contributors

[![MarkusBiggus](https://avatars.githubusercontent.com/u/6531552?v=4)](https://github.com/MarkusBiggus "MarkusBiggus (5 commits)")

### Embed Badge

![Health badge](/badges/markusbiggus-stateengine/health.svg)

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

PHPackages © 2026

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