PHPackages                             hyn/state-machine - 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. [Database &amp; ORM](/categories/database)
4. /
5. hyn/state-machine

ActiveLibrary[Database &amp; ORM](/categories/database)

hyn/state-machine
=================

Flexible state machine library that perfectly works with Laravels Eloquent models.

4.0.0(4mo ago)162.5k↓100%1mitPHPPHP &gt;=8.1CI failing

Since Oct 12Pushed 4mo ago3 watchersCompare

[ Source](https://github.com/hyn/state-machine)[ Packagist](https://packagist.org/packages/hyn/state-machine)[ RSS](/packages/hyn-state-machine/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (15)Used By (0)

State machine
=============

[](#state-machine)

The state machine is a flexible library that helps you move Eloquent models from States through Transitions while emitting events along the way.

Example
-------

[](#example)

Let's say we have a [Cat](tests/stubs/Models/Cat.php), who does two things, being

- [Asleep](tests/stubs/States/Cat/Asleep.php) and
- [Awake](tests/stubs/States/Cat/Awake.php)

In order to become Awake from his initial state being Asleep, the cat has to

- [WakeUp](tests/stubs/Transitions/Cat/WakesUp.php)

Now if we look at the [state machine definition](tests/stubs/Definitions/CatDefinition.php) we can see the above is perfectly mapped out.

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

[](#installation)

```
composer require hyn/state-machine
```

**Read more** about installation and configuration on [state-machine.readme.io](https://state-machine.readme.io/docs).

Tests
-----

[](#tests)

Run the tests with:

```
vendor/bin/phpunit
```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance82

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity79

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

Recently: every ~216 days

Total

13

Last Release

121d ago

Major Versions

1.0.6 → 2.0.02022-05-13

2.0.0 → 3.0.02023-08-24

3.0.3 → 4.0.02026-01-07

PHP version history (4 changes)1.0.0PHP &gt;=7.0.0

1.0.6PHP &gt;=7.1

2.0.0PHP &gt;=8.0

3.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/504687?v=4)[Daniël Klabbers](/maintainers/Luceos)[@luceos](https://github.com/luceos)

---

Top Contributors

[![luceos](https://avatars.githubusercontent.com/u/504687?v=4)](https://github.com/luceos "luceos (33 commits)")

---

Tags

eloquentevent-dispatcherlaravelstate-machine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hyn-state-machine/health.svg)

```
[![Health](https://phpackages.com/badges/hyn-state-machine/health.svg)](https://phpackages.com/packages/hyn-state-machine)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[matanyadaev/laravel-eloquent-spatial

Spatial library for Laravel

3982.9M15](/packages/matanyadaev-laravel-eloquent-spatial)[overtrue/laravel-versionable

Make Laravel model versionable.

585308.0k5](/packages/overtrue-laravel-versionable)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)[dragon-code/laravel-deploy-operations

Performing any actions during the deployment process

240173.5k2](/packages/dragon-code-laravel-deploy-operations)[stayallive/laravel-eloquent-observable

Register Eloquent model event listeners just-in-time directly from the model.

2928.9k6](/packages/stayallive-laravel-eloquent-observable)

PHPackages © 2026

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