hyn / state-machine by Luceos

Flexible state machine library that perfectly works with Laravels Eloquent models.
2,033
15
5
Package Data
Maintainer Username: Luceos
Package Create Date: 2016-10-12
Package Last Update: 2023-11-30
Home Page: https://state-machine.readme.io/docs
Language: PHP
License: mit
Last Refreshed: 2024-05-03 03:05:26
Package Statistics
Total Downloads: 2,033
Monthly Downloads: 11
Daily Downloads: 0
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