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

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

caner/state-machine
===================

Laravel Simple State Machine System

1.1.0(4y ago)51202MITPHPPHP ^8.0

Since Jan 12Pushed 4y ago6 watchersCompare

[ Source](https://github.com/CanerErgez/laravel-state-machine)[ Packagist](https://packagist.org/packages/caner/state-machine)[ Docs](https://github.com/CanerErgez/state-machine)[ RSS](/packages/caner-state-machine/feed)WikiDiscussions main Synced 1mo ago

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

Laravel State Machine
=====================

[](#laravel-state-machine)

[![Latest Version on Packagist](https://camo.githubusercontent.com/89b1b9deb5846cab74ba3e16048881604d7e9c937c81b44c91b49a151a4248f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f63616e65722f73746174652d6d616368696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/caner/state-machine)[![Total Downloads](https://camo.githubusercontent.com/61b2bd76510e309a8db75ef6e87edc64fa1b41432c0164bf5bc30e7a79c62280/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f63616e65722f73746174652d6d616368696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/caner/state-machine)[![run-tests](https://github.com/CanerErgez/laravel-state-machine/actions/workflows/main.yml/badge.svg?branch=main)](https://github.com/CanerErgez/laravel-state-machine/actions/workflows/main.yml)

This package helps you to create State Machine data model-based services.

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

[](#installation)

You can install the package via composer:

```
composer require caner/state-machine
```

Usage
-----

[](#usage)

In `config/app.php`;

```
\Caner\StateMachine\StateMachineServiceProvider::class,
```

and publish config file;

```
php artisan vendor:publish --tag=caner-state-machine-config
```

### Step by step documentation

[](#step-by-step-documentation)

#### Introducing Concept

[](#introducing-concept)

A state machine is a mathematical abstraction used to design algorithms. A state machine reads a set of inputs and changes to a different state based on those inputs.

A state is a description of the status of a system waiting to execute a transition. A transition is a set of actions to execute when a condition is fulfilled or an event received. In a state diagram, circles represent each possible state and arrows represent transitions between states.

Basically, we are building a `state` for each `status` and running related `transition` when changing the `status`.

[![Sample State Change Workflow](https://github.com/CanerErgez/laravel-state-machine/raw/main/docs/img/1.png)](https://github.com/CanerErgez/laravel-state-machine/raw/main/docs/img/1.png)

Each `Transition` should consist of 3 parts. These are the `guards`, `action` and `afterActions` methods.

[![Sample Transition Workflow](https://github.com/CanerErgez/laravel-state-machine/raw/main/docs/img/2.png)](https://github.com/CanerErgez/laravel-state-machine/raw/main/docs/img/2.png)

I prefer to use package in complex status changes.

Preferred Directory Tree;

- app
- - Services
- - - YourStateMachine
- - - - AfterActions
- - - - Guards
- - - - States
- - - - Transitions
- - - - YourStateMachine.php
- - - AnotherStateMachine
- - - - AfterActions
- - - - Guards
- - - - States
- - - - Transitions
- - - - AnotherStateMachine.php

In future versions, we will be added, create state machine parts in artisan commands. This time commands run like this directory tree.

[1-) Create First State Machine ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/first_state_machine.md)
[2-) Create First State ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/first_state.md)
[3-) Create First Transition ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/first_transition.md)
[4-) Create First Guard ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/first_guard.md)
[5-) Create First AfterAction ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/first_after_action.md)
[6-) Example Transition in Created State Machine ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/example_transition.md)
[7-) Create Another State Machine ](https://github.com/CanerErgez/laravel-state-machine/tree/main/docs/create_another_state_machine.md)

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please create an issue on github issues section.

Credits
-------

[](#credits)

Special thanks for [Tarfin Labs](https://github.com/tarfin-labs)

- [Caner Ergez](https://github.com/CanerErgez)
- Will be update soon.

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity59

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

Every ~19 days

Total

3

Last Release

1548d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/21d3476626be33ce8a33692f025e5a2c797c97bfc1ec08cdba37eb3dd6b8d2ad?d=identicon)[CanerErgez](/maintainers/CanerErgez)

---

Top Contributors

[![CanerErgez](https://avatars.githubusercontent.com/u/10279602?v=4)](https://github.com/CanerErgez "CanerErgez (10 commits)")

---

Tags

laravelstate-machinecaner

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[ringierimu/state-workflow

Laravel State Workflow provide tools for defining and managing workflows and activities with ease.

3251.1k](/packages/ringierimu-state-workflow)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[nedwors/navigator

A Laravel package to ease defining navigation menus

433.1k](/packages/nedwors-navigator)[dcblogdev/laravel-junie

Install pre-configured guides for Jetbrains Junie

392.5k](/packages/dcblogdev-laravel-junie)

PHPackages © 2026

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