PHPackages                             anon767/stateeventbroker - 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. anon767/stateeventbroker

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

anon767/stateeventbroker
========================

Advanced Stateautomaton for Eventbroker

18PHP

Since Jul 27Pushed 7y agoCompare

[ Source](https://github.com/anon767/stateeventbroker)[ Packagist](https://packagist.org/packages/anon767/stateeventbroker)[ RSS](/packages/anon767-stateeventbroker/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Advanced Eventdriven State Automaton
====================================

[](#advanced-eventdriven-state-automaton)

This Library provides managing state and state-transitions. It applies rules by considering the current state and the incoming events. It can handle multiple events aswell what makes it actually a pushdown automaton.

Install
-------

[](#install)

```
composer require anon767/stateeventbroker

```

Or

```
"require": {
    "anon767/stateeventbroker": "*"
  }

```

Usage
-----

[](#usage)

First you should define some Events lets start with a simple example:

```
define("IDLE_STATE", "idle");
define("CLEAN_STATE", "cleaning");
define("DOOR_CLOSED_EVENT", "doorcloses");
define("ITSSIXOCLOCK_EVENT", "sixoclock");
```

These are basically two States and events. Now its time to program the automaton. This is quite easy and works like that:

```
$rules = [
 ["oldState" => IDLE_STATE, "event" => new Events([new Event(DOOR_CLOSED_EVENT), new Event(ITSSIXOCLOCK_EVENT)]), "action" => $startRobo, "newState" => CLEAN_STATE],
  ["oldState" => CLEAN_STATE, "event" => new Event(DOOR_CLOSED_EVENT), "action" => $stopRobo, "newState" => IDLE_STATE],
];
```

You see? If the automaton is in Idle State and the two above defined events came in we let the library trigger the "startRobo" callback and transit to the next state "CLEAN\_STATE". If we are in the CLEAN\_STATE and the door closed event comes in, we trigger a stopRobo callback and go back to the Idle state.

```
$startRobo = function (Event $event) {
  $this->assertEquals(ITSSIXOCLOCK_EVENT, $event->identifier);
};

$stopRobo = function (Event $event) {
  $this->assertEquals(DOOR_CLOSED_EVENT, $event->identifier);
};
```

These are the two callbacks from the Test Case. They get executed if the above mentioned transitions kicked in.

Using the actual state automaton is as simple as:

```
$this->stateAutomaton = new StateAutomaton(IDLE_STATE);
$this->broker = new Broker($this->stateAutomaton);
$this->stateAutomaton->addRules($rules);
//for example following event comes in:
$this->broker->onMessage(DOOR_CLOSED_EVENT);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e17da740e35c6f38186b3f3961f96f8d78f0ae1660b9bc11163131ca65092e6?d=identicon)[anon767](/maintainers/anon767)

---

Top Contributors

[![anon767](https://avatars.githubusercontent.com/u/20929982?v=4)](https://github.com/anon767 "anon767 (2 commits)")

### Embed Badge

![Health badge](/badges/anon767-stateeventbroker/health.svg)

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

###  Alternatives

[wnx/php-swiss-cantons

Search for Swiss Cantons by name or abbreviation.

1855.4k2](/packages/wnx-php-swiss-cantons)[nami-doc/sprockets-php

Sprockets-PHP is Sprockets (Rails Asset Pipeline) for PHP

496.1k](/packages/nami-doc-sprockets-php)

PHPackages © 2026

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