hyn / state-machine
Flexible state machine library that perfectly works with Laravels Eloquent models.
Installs: 2 397
Dependents: 0
Suggesters: 0
Security: 0
Stars: 15
Watchers: 5
Forks: 1
Open Issues: 0
Requires
- php: >=8.1
- laravel/framework: ^9.0 | ^10
Requires (Dev)
- phpunit/phpunit: ^9.5.10
README
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