PHPackages                             thetwelvelabs/techne - 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. thetwelvelabs/techne

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

thetwelvelabs/techne
====================

Finite State Machine implementation

0.2.x-dev(13y ago)412.4k↓33.3%1MITPHPPHP &gt;=5.3.3

Since Nov 18Pushed 13y ago1 watchersCompare

[ Source](https://github.com/chriswoodford/techne)[ Packagist](https://packagist.org/packages/thetwelvelabs/techne)[ Docs](http://thetwelvelabs.com)[ RSS](/packages/thetwelvelabs-techne/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Finite-State Machine Library
============================

[](#finite-state-machine-library)

================================

A simple PHP implementation of a [Finite-State Machine](http://en.wikipedia.org/wiki/Finite-state_machine)

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

[](#installation)

---

Use [Composer](http://getcomposer.org) to install this library in your project

### Create your composer.json file

[](#create-your-composerjson-file)

```
  {
      "require": {
          "thetwelvelabs/techne": "0.2.*@dev"
      }
  }

```

### Download composer into your application root

[](#download-composer-into-your-application-root)

```
  $ curl -s http://getcomposer.org/installer | php

```

### Install your dependencies

[](#install-your-dependencies)

```
  $ php composer.phar install

```

Usage
-----

[](#usage)

---

Let's use a light switch as a simple example.
A light switch as two states: on and off. The state of a light switch is transitioned from one to the other by flipping the switch. We'll assume that the initial state of the light switch is 'off'

### Define your FSM

[](#define-your-fsm)

```
  $machine = new StateMachine\FiniteStateMachine();
  $machine->setInitialState('off');

```

### Define the transitions

[](#define-the-transitions)

```
  $turnOff = new StateMachine\Transition('on', 'off');
  $turnOn = new StateMachine\Transition('off', 'on');

```

### Add a guard to the turnOn transition

[](#add-a-guard-to-the-turnon-transition)

```
  // flipping the switch on requires electricity
  $hasElectricity = true;
  $turnOn->before(function() use ($hasElectricity) {
      return $hasElectricity ? true : false;
  });

```

Define the events
-----------------

[](#define-the-events)

```
  $machine->addEvent('flip', array($turnOn, $turnOff));

```

### Transition from off to on

[](#transition-from-off-to-on)

```
  $machine->flip();
  echo $machine->getCurrentState();
  // prints 'on'

```

### Transition back to off

[](#transition-back-to-off)

```
  $machine->flip();
  echo $machine->getCurrentState();
  // prints 'off'

```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity45

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 ~72 days

Total

2

Last Release

4857d ago

### Community

Maintainers

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

---

Top Contributors

[![chriswoodford](https://avatars.githubusercontent.com/u/249055?v=4)](https://github.com/chriswoodford "chriswoodford (12 commits)")

---

Tags

fsmfinite-state machine

### Embed Badge

![Health badge](/badges/thetwelvelabs-techne/health.svg)

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

###  Alternatives

[eftec/statemachineone

A state Machine library for business processes

1144.0k](/packages/eftec-statemachineone)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

188.5k](/packages/tarfin-labs-event-machine)[pwm/s-flow

A lightweight library for defining state machines

742.5k](/packages/pwm-s-flow)[shrink0r/workflux

Finite state machine for php.

375.6k1](/packages/shrink0r-workflux)[daveawb/understated

A PHP Finite State Machine for Laravel 5+

302.0k](/packages/daveawb-understated)[phpmentors/stagehand-fsm

A finite state machine

361.1k](/packages/phpmentors-stagehand-fsm)

PHPackages © 2026

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