hyn/state-machine

Flexible state machine library that perfectly works with Laravels Eloquent models.
2,499 16
Install
composer require hyn/state-machine
Latest Version:4.0.0
PHP:>=8.1
License:mit
Last Updated:Jan 7, 2026
Links: GitHub  ·  Packagist
Maintainer: Luceos

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

Let's say we have a Cat, who does two things, being

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

Now if we look at the state machine definition we can see the above is perfectly mapped out.

Installation

composer require hyn/state-machine

Read more about installation and configuration on state-machine.readme.io.

Tests

Run the tests with:

vendor/bin/phpunit

Related Packages

erirk/paypalpayment

laravel-paypalpayment is simple package help you process direct credit card paym...

0
gabrieloliverio/laravel5-generators

Database metadata-based generators for Laravel 5

1
doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

617,346,630 9,703
laravel/framework

The Laravel Framework.

561,395,438 34,860
laravel/tinker

Powerful REPL for the Laravel framework.

471,804,685 7,440