PHPackages                             halfowl/statemachine - 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. halfowl/statemachine

ActiveLibrary

halfowl/statemachine
====================

State Machines made safe and easy.

v1.0.0(3y ago)110[1 issues](https://github.com/half0wl/php-StateMachine/issues)MITPHPPHP &gt;=7.4

Since Oct 23Pushed 3y ago1 watchersCompare

[ Source](https://github.com/half0wl/php-StateMachine)[ Packagist](https://packagist.org/packages/halfowl/statemachine)[ RSS](/packages/halfowl-statemachine/feed)WikiDiscussions main Synced 1mo ago

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

php-StateMachine
================

[](#php-statemachine)

[![Latest Stable Version](https://camo.githubusercontent.com/77bf506ffbb237f4471de2853a44eab22405cb4f10b2e998867604b3e0479b1f/687474703a2f2f706f7365722e707567782e6f72672f68616c666f776c2f73746174656d616368696e652f76)](https://packagist.org/packages/halfowl/statemachine) [![Total Downloads](https://camo.githubusercontent.com/4c85d4ba34bf67b8a160df616b966c5dca0f9b5c63ec19d4fdafacf1faa82482/687474703a2f2f706f7365722e707567782e6f72672f68616c666f776c2f73746174656d616368696e652f646f776e6c6f616473)](https://packagist.org/packages/halfowl/statemachine) [![License](https://camo.githubusercontent.com/e5feadf68c67d675de9151c55a4548a41c4bc8376e8eee13054fd96748f51f0d/687474703a2f2f706f7365722e707567782e6f72672f68616c666f776c2f73746174656d616368696e652f6c6963656e7365)](https://packagist.org/packages/halfowl/statemachine) [![PHP Version Require](https://camo.githubusercontent.com/9785ea2333f686a30fcbb7a578a4c5a3ce75dfe84ecd03a69e1d8976bf187403/687474703a2f2f706f7365722e707567782e6f72672f68616c666f776c2f73746174656d616368696e652f726571756972652f706870)](https://packagist.org/packages/halfowl/statemachine)

State Machines in PHP made safe and easy.

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

[](#installation)

Using Composer:

```
$ composer require halfowl/statemachine

```

Example
-------

[](#example)

Imagine an application that holds the state of an article. It has the following states:

- Draft
- Awaiting Copy Edit
- Published

A new article starts in "Draft", gets progressed to "Awaiting Copy Edit", and subsequently "Published". An article in "Awaiting Copy Edit" can go back to being a "Draft".

With this library, you can model the above as:

```
