PHPackages                             juststeveking/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. juststeveking/state-machine

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

juststeveking/state-machine
===========================

A small, framework-agnostic PHP state machine for modeling valid transitions between states.

1.0.0(3w ago)290↓43.8%MITPHPPHP ^8.5CI passing

Since May 13Pushed 3w agoCompare

[ Source](https://github.com/JustSteveKing/state-machine)[ Packagist](https://packagist.org/packages/juststeveking/state-machine)[ GitHub Sponsors](https://github.com/juststeveking)[ RSS](/packages/juststeveking-state-machine/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

State Machine
=============

[](#state-machine)

A small, framework-agnostic PHP state machine for modeling valid transitions between states.

It is built around three contracts:

- `StateContract`
- `TransitionContract`
- `StateMachineContract`

You define your own states, transitions, and domain events. The package validates transitions and throws clear exceptions when a transition is invalid.

Requirements
------------

[](#requirements)

- PHP 8.5+

Installation
------------

[](#installation)

```
composer require juststeveking/state-machine
```

30-Second Quick Start
---------------------

[](#30-second-quick-start)

If you already have your own states and transitions, this is the smallest working flow:

```
