PHPackages                             chareice/finite - 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. chareice/finite

ActiveLibrary

chareice/finite
===============

A simple PHP5.3+ Finite State Machine

1.0.3(12y ago)056MITPHPPHP &gt;=5.3.0

Since Mar 4Pushed 11y ago1 watchersCompare

[ Source](https://github.com/chareice/Finite)[ Packagist](https://packagist.org/packages/chareice/finite)[ Docs](https://github.com/yohang/Finite)[ RSS](/packages/chareice-finite/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (10)Versions (10)Used By (0)

Finite, A Simple PHP Finite State Machine
=========================================

[](#finite-a-simple-php-finite-state-machine)

Finite is a Simple State Machine, written in PHP. It can manage any Stateful object by defining states and transitions between these states.

[![Build Status](https://camo.githubusercontent.com/0ac5eb03eb772a408344d0a6373ca5c81bc13c4096ad427f9691050a9ccc6f7b/68747470733a2f2f7472617669732d63692e6f72672f796f68616e672f46696e6974652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yohang/Finite)[![Latest Stable Version](https://camo.githubusercontent.com/d9799ce4a392cf16b187d96a2472036df7aaec7723b7d6eb26c52df72eba18e0/68747470733a2f2f706f7365722e707567782e6f72672f796f68616e672f66696e6974652f762f737461626c652e706e67)](https://packagist.org/packages/yohang/finite)[![Total Downloads](https://camo.githubusercontent.com/f9accacb3e30ef9f5f8b77f1bd2f26b2765848efe1506bd04c280d4702a2774a/68747470733a2f2f706f7365722e707567782e6f72672f796f68616e672f66696e6974652f646f776e6c6f6164732e706e67)](https://packagist.org/packages/yohang/finite)[![License](https://camo.githubusercontent.com/7786e18942a01b088ba0a240143308b79b3e03875c963196f8a95bbdeb3dd66b/68747470733a2f2f706f7365722e707567782e6f72672f796f68616e672f66696e6974652f6c6963656e73652e706e67)](https://packagist.org/packages/yohang/finite)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/66e6557f87a15393f81b1ba5e2d8f8ce45171cdb5593d6458f28b760482a7a06/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796f68616e672f46696e6974652f6261646765732f7175616c6974792d73636f72652e706e673f733d64366237346434366533653366363634333132373065633339323034643938373634636231326362)](https://scrutinizer-ci.com/g/yohang/Finite/)[![Code Coverage](https://camo.githubusercontent.com/16037100b2833c1ed887c122d623c7c47305cce031b7f2f6c97907534b82fa56/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796f68616e672f46696e6974652f6261646765732f636f7665726167652e706e673f733d65313339396639306132656134326634393733653862643739303536353430666638646530636534)](https://scrutinizer-ci.com/g/yohang/Finite/)[![SensioLabsInsight](https://camo.githubusercontent.com/22ce47d7e9de57215e8be20e5bc52541439c5671174bdf13bb4cc4c09e54de27/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f33393466336138652d653663352d343130322d383937392d6433383964623264303239332f6d696e692e706e67)](https://insight.sensiolabs.com/projects/394f3a8e-e6c5-4102-8979-d389db2d0293)

Features
--------

[](#features)

- Managing State/Transition graph for an object
- Defining and retrieving properties for states
- Event Listenable transitions
- Symfony2 integration
- Custom state graph loaders
- Twig Extension

Getting started
---------------

[](#getting-started)

### Installation (via composer)

[](#installation-via-composer)

```
{
      "require": {
        "yohang/finite": "~1.1"
    }
}
```

### Define your Stateful Object

[](#define-your-stateful-object)

Your stateful object just need to implement the `StatefulInterface` Interface.

```
use Finite\StatefulInterface;

class Document implements StatefulInterface
{
        private $state;
        public function setFiniteState($state)
        {
                $this->state = $state;
        }

        public function getFiniteState()
        {
            return $this->state;
        }
}
```

### Initializing a simple StateMachine

[](#initializing-a-simple-statemachine)

```
use Finite\StateMachine\StateMachine;
use Finite\State\State;
use Finite\State\StateInterface;

// $document = retrieve your stateful object

$sm = new StateMachine();

// Define states
$sm->addState(new State('s1', StateInterface::TYPE_INITIAL));
$sm->addState('s2');
$sm->addState('s3');
$sm->addState(new State('s4', StateInterface::TYPE_FINAL));

// Define transitions
$sm->addTransition('t12', 's1', 's2');
$sm->addTransition('t23', 's2', 's3');
$sm->addTransition('t34', 's3', 's4');
$sm->addTransition('t42', 's4', 's2');

// Initialize
$sm->setObject($document);
$sm->initialize();

// Retrieve current state
$sm->getCurrentState();

// Can we process a transition ?
$sm->can('t34');
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~71 days

Recently: every ~16 days

Total

7

Last Release

4391d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f75e764b0a3f4a3f92cbe0a60510bd45f3e24e9160a8c730f3fdd9c4d94ed398?d=identicon)[chareice](/maintainers/chareice)

---

Top Contributors

[![yohang](https://avatars.githubusercontent.com/u/608984?v=4)](https://github.com/yohang "yohang (112 commits)")[![winzou](https://avatars.githubusercontent.com/u/702928?v=4)](https://github.com/winzou "winzou (10 commits)")[![Padam87](https://avatars.githubusercontent.com/u/776488?v=4)](https://github.com/Padam87 "Padam87 (3 commits)")[![chareice](https://avatars.githubusercontent.com/u/1624785?v=4)](https://github.com/chareice "chareice (3 commits)")[![liuggio](https://avatars.githubusercontent.com/u/530406?v=4)](https://github.com/liuggio "liuggio (2 commits)")[![tortuetorche](https://avatars.githubusercontent.com/u/5038872?v=4)](https://github.com/tortuetorche "tortuetorche (2 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![tompedals](https://avatars.githubusercontent.com/u/6132043?v=4)](https://github.com/tompedals "tompedals (1 commits)")[![nidup](https://avatars.githubusercontent.com/u/2104359?v=4)](https://github.com/nidup "nidup (1 commits)")[![dannykopping](https://avatars.githubusercontent.com/u/373762?v=4)](https://github.com/dannykopping "dannykopping (1 commits)")[![defrag](https://avatars.githubusercontent.com/u/15900?v=4)](https://github.com/defrag "defrag (1 commits)")[![K-Phoen](https://avatars.githubusercontent.com/u/66958?v=4)](https://github.com/K-Phoen "K-Phoen (1 commits)")[![ksn135](https://avatars.githubusercontent.com/u/230304?v=4)](https://github.com/ksn135 "ksn135 (1 commits)")[![arikal](https://avatars.githubusercontent.com/u/3074809?v=4)](https://github.com/arikal "arikal (1 commits)")

---

Tags

statemachine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chareice-finite/health.svg)

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

###  Alternatives

[symfony/form

Allows to easily create, process and reuse HTML forms

2.8k152.1M2.8k](/packages/symfony-form)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[friendsofsymfony/http-cache

Tools to manage HTTP caching proxies with PHP

36114.7M36](/packages/friendsofsymfony-http-cache)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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