hyn / state-machine by Luceos

Flexible state machine library that perfectly works with Laravels Eloquent models.
2,414
15
5
Package Data
Maintainer Username: Luceos
Package Create Date: 2016-10-12
Package Last Update: 2024-06-14
Home Page: https://state-machine.readme.io/docs
Language: PHP
License: mit
Last Refreshed: 2024-12-14 15:07:40
Package Statistics
Total Downloads: 2,414
Monthly Downloads: 25
Daily Downloads: 3
Total Stars: 15
Total Watchers: 5
Total Forks: 1
Total Open Issues: 0

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