PHPackages                             particle/state - 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. particle/state

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

particle/state
==============

A rather simplistic but pretty finite state machine implementation

0.1.0(10y ago)12242BSDPHPPHP &gt;=5.4

Since Apr 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/particle-php/State)[ Packagist](https://packagist.org/packages/particle/state)[ Docs](http://github.com/particle-php/state)[ RSS](/packages/particle-state/feed)WikiDiscussions master Synced 2mo ago

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

Particle\\State
===============

[](#particlestate)

*Particle\\State* is a very small and simple library, implementing a finite state machine. You can use it in your application whenever you need to account for transitions between multiple states (and that's probably more often than you would imagine!).

### Why?

[](#why)

With [winzou/statemachine](https://github.com/winzou/state-machine) and [yohang/finite](https://github.com/yohang/Finite) already in Packagist, why would we go for another package implementing the very same concept?

Well, first of all, Particle\\State is very small in comparison, doing next to nothing. That means everything it *does* do is easy to follow, without having to wade through lots of code. Also, by doing only one thing, it's rather easy to learn how to use this library.

On top of that, we wanted to have a library that is not obtrusive: you can implement *Particle\\State* without having to model your objects in a certain way. Indeed, *Particle\\State* does not have any interface you need to implement.

Nevertheless, check them out. Maybe they'll serve you better.

Small usage example
-------------------

[](#small-usage-example)

```
$initialState = State::withName('pending');

$machine = StateMachine::withStates($initialState, StateCollection::withStates([
    State::withName('pending'),
    State::withName('started'),
    State::withName('accepted'),
    State::withName('rejected'),
    State::withName('completed'),
    State::withName('failed'),
]));

$machine->addTransition(Transition::withStates('start', ['pending'], 'started'));
$machine->addTransition(Transition::withStates('accept', ['started'], 'accepted'));

$machine->addListener(function (Event\TransitionApplied $event) {
    if ($event->wasFromState(State:withName('pending')) {
        echo "The state was pending. Not anymore though :)";
    }
});

var_dump($machine->canApplyTransition('accept')); // bool(false), because not in 'started' state;
var_dump($machine->canApplyTransition('start')); // bool(true);
var_dump($machine->transition('start')); // bool(true);
var_dump($machine->canApplyTransition('accept')); // bool(true);
var_dump($machine->canApplyTransition('start')); // bool(false);
```

Functional features
-------------------

[](#functional-features)

- Validate if a transition of state is possible;
- Transition the state to a next state;
- Hook event listeners to state changes as transition callbacks.

Non functional features
-----------------------

[](#non-functional-features)

- Easy to write (IDE auto-completion for easy development)
- Easy to read (improves peer review)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3686d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6169c8b4657a79f3a96b4f167abc794d76402db6e4c0ad4bfe0c9b71fa8b2ef1?d=identicon)[berry\_\_](/maintainers/berry__)

---

Top Contributors

[![berry-langerak](https://avatars.githubusercontent.com/u/203825?v=4)](https://github.com/berry-langerak "berry-langerak (2 commits)")

---

Tags

statefsmfinitemachine

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/particle-state/health.svg)

```
[![Health](https://phpackages.com/badges/particle-state/health.svg)](https://phpackages.com/packages/particle-state)
```

###  Alternatives

[symfony/workflow

Provides tools for managing a workflow or finite state machine

62842.3M170](/packages/symfony-workflow)[yohang/finite

A simple PHP Finite State Machine

1.3k3.5M10](/packages/yohang-finite)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[sebdesign/laravel-state-machine

Winzou State Machine service provider for Laravel

3401.3M1](/packages/sebdesign-laravel-state-machine)[rolfvreijdenberger/izzum-statemachine

A superior statemachine library php &gt;= 5.3. Integrates with your domain models perfectly.

7425.5k](/packages/rolfvreijdenberger-izzum-statemachine)[dougsisk/laravel-country-state

Country &amp; state helper for Laravel.

1681.7M](/packages/dougsisk-laravel-country-state)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
