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(5mo ago)162.5k1mitPHPPHP &gt;=8.1CI failing

Since Oct 12Pushed 5mo 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 2w 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

50

—

FairBetter than 95% of packages

Maintenance70

Regular maintenance activity

Popularity24

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

166d 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

11222.5M32](/packages/anourvalar-eloquent-serialize)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[mozex/laravel-scout-bulk-actions

Import, flush, and queue-import all your Laravel Scout searchable models at once. Auto-discovers models, runs in bulk, tracks progress.

1437.7k](/packages/mozex-laravel-scout-bulk-actions)[ramadan/easy-model

A Laravel package for enjoyably managing database queries.

111.6k](/packages/ramadan-easy-model)

PHPackages © 2026

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