PHPackages                             tarfin-labs/event-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. tarfin-labs/event-machine

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

tarfin-labs/event-machine
=========================

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

9.13.0(1w ago)199.4k↓46.7%1[4 PRs](https://github.com/tarfin-labs/event-machine/pulls)MITPHPPHP ^8.3|^8.4|^8.5CI passing

Since Apr 11Pushed 1w ago6 watchersCompare

[ Source](https://github.com/tarfin-labs/event-machine)[ Packagist](https://packagist.org/packages/tarfin-labs/event-machine)[ Docs](https://github.com/tarfin-labs/event-machine)[ RSS](/packages/tarfin-labs-event-machine/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (65)Versions (243)Used By (0)

  ![EventMachine](./art/event-machine-logo-light.svg)[![Latest Version on Packagist](https://camo.githubusercontent.com/b082a277e4793698ccb8eb8911a04e588befefc220601183531469755e616eeb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74617266696e2d6c6162732f6576656e742d6d616368696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tarfin-labs/event-machine)[![GitHub Tests Action Status](https://camo.githubusercontent.com/8cc0c55e20dc91007feb98a4080a31a1843d8f486bd4708c3270d6a148ac713c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74617266696e2d6c6162732f6576656e742d6d616368696e652f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/tarfin-labs/event-machine/actions?query=workflow%3ACI+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/81e3124d80ed73b96f12b416209e350c41c3c64e4675675c7a42e40e78d99b37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74617266696e2d6c6162732f6576656e742d6d616368696e652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tarfin-labs/event-machine)

**Event-driven state machines for Laravel**

[Documentation](https://eventmachine.dev) · [Installation](#installation) · [Why EventMachine?](#why-eventmachine)

---

Why EventMachine?
-----------------

[](#why-eventmachine)

**Your business logic deserves better than nested if-statements.**

EventMachine brings the power of finite state machines to Laravel, inspired by [XState](https://xstate.js.org). Define your states, transitions, and behaviors declaratively - and let the machine handle the complexity.

### The Problem

[](#the-problem)

```
// Without state machines: scattered conditionals, hidden rules, impossible to test
if ($order->status === 'pending' && $user->can('approve') && !$order->isExpired()) {
    if ($order->total > 10000 && !$order->hasSecondApproval()) {
        // More nested logic...
    }
}
```

### The Solution

[](#the-solution)

```
// With EventMachine: clear states, explicit transitions, testable behaviors
MachineDefinition::define(
    config: [
        'initial' => 'pending',
        'states' => [
            'pending' => [
                'on' => [
                    'APPROVE' => [
                        'target' => 'approved',
                        'guards' => [CanApproveGuard::class, NotExpiredGuard::class],
                    ],
                ],
            ],
            'approved' => [
                'entry' => NotifyCustomerAction::class,
            ],
        ],
    ],
);
```

### Key Benefits

[](#key-benefits)

FeatureDescription**Event Sourced**Every transition persisted. Full audit trail. Replay history.**Behaviors**Guards validate, calculators compute, actions execute.**Parallel Dispatch**True parallel execution via Laravel queues. 5s + 2s = 5s, not 7s.**Testable**Fake any behavior. Assert states. Verify transitions.**Type-Safe Context**Spatie Data powered. Validated. IDE autocompletion.**Archival**Compress millions of events. Restore any machine instantly.**Laravel Native**Eloquent, DI, Artisan commands. Built for Laravel.Installation
------------

[](#installation)

```
composer require tarfin-labs/event-machine
```

```
php artisan vendor:publish --tag="event-machine-migrations"
php artisan migrate
```

AI Agent Skill
--------------

[](#ai-agent-skill)

EventMachine ships with an official [Agent Skill](https://agentskills.io) so AI coding agents can write correct, idiomatic EventMachine code — it loads naming conventions, best practices, testing patterns, and the full VitePress documentation on demand.

Install via [`npx skills`](https://github.com/vercel-labs/skills) — works with **45+ agents** including Claude Code, Cursor, GitHub Copilot, Cline, Codex, OpenCode, Gemini CLI, Warp, Amp, and many others:

```
npx skills add tarfin-labs/event-machine#plugin-dist
```

The CLI detects your installed agents and wires the skill into the right location. The `plugin-dist` branch is a self-contained, materialized snapshot published automatically on every release tag.

What the skill loads:

- **Immediately** (when the skill triggers): naming conventions, 13 best-practice summaries, core concepts, quick-start snippets, testing API cheat-sheet, Laravel integration map, delegation/parallel gotcha tables.
- **On demand** (when the agent needs deeper detail): curated cheat-sheets under `references/` and the full 87-page documentation under `docs/`.

Read the full skill guide at [eventmachine.dev/getting-started/agent-skill](https://eventmachine.dev/getting-started/agent-skill).

Support Policy
--------------

[](#support-policy)

Only the **latest major version** (currently v7) receives bug fixes and security patches. All previous versions are end of life. See the [Upgrading Guide](https://eventmachine.dev/getting-started/upgrading) for step-by-step migration from any version.

Eloquent Integration
--------------------

[](#eloquent-integration)

```
class Order extends Model
{
    use HasMachines;

    protected $casts = [
        'machine' => MachineCast::class.':'.OrderMachine::class,
    ];
}

// Use it naturally
$order = Order::create();
$order->machine->send(['type' => 'SUBMIT']);
$order->machine->send(['type' => 'APPROVE']);

$order->machine->state->matches('approved'); // true
$order->machine->state->history->count();    // 3 events tracked
```

Documentation
-------------

[](#documentation)

For guards, actions, calculators, hierarchical states, parallel dispatch, validation, testing, and more:

**[Read the Documentation →](https://event-machine.tarfin.com)**

Credits
-------

[](#credits)

- [Yunus Emre Deligöz](https://github.com/deligoez)
- [Fatih Aydın](https://github.com/aydinfatih)
- [Yunus Emre Nalbant](https://github.com/YunusEmreNalbant)
- [Faruk Can](https://github.com/frkcn)
- [Turan Karatuğ](https://github.com/tkaratug)
- [Yılmaz Demir](https://github.com/yidemir)
- Maybe you? [Contribute →](../../contributing)

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE.md) for details.

###  Health Score

62

—

FairBetter than 99% of packages

Maintenance98

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 94.5% 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 ~9 days

Total

104

Last Release

10d ago

Major Versions

5.1.2 → 6.0.02026-03-10

6.4.0 → v7.0.02026-03-16

7.9.2 → v8.0.x-dev2026-03-20

8.7.2 → v9.x-dev2026-03-26

8.7.3 → 9.0.02026-03-31

PHP version history (5 changes)1.0.0PHP ^8.2

1.3.0PHP ^8.2|^8.3

2.1.0PHP ^8.2|^8.3|^8.4

v3.x-devPHP ^8.2|^8.3|^8.4|^8.5

4.0.0PHP ^8.3|^8.4|^8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/e252316490c5fc7bae7eb25b6c0cb301b49fbc706c32896fea9467b64cf3653b?d=identicon)[Tarfin Labs](/maintainers/Tarfin%20Labs)

---

Top Contributors

[![deligoez](https://avatars.githubusercontent.com/u/3030815?v=4)](https://github.com/deligoez "deligoez (3584 commits)")[![aydinfatih](https://avatars.githubusercontent.com/u/14280894?v=4)](https://github.com/aydinfatih "aydinfatih (116 commits)")[![YunusEmreNalbant](https://avatars.githubusercontent.com/u/29780061?v=4)](https://github.com/YunusEmreNalbant "YunusEmreNalbant (31 commits)")[![frkcn](https://avatars.githubusercontent.com/u/374634?v=4)](https://github.com/frkcn "frkcn (30 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (15 commits)")[![tkaratug](https://avatars.githubusercontent.com/u/4394344?v=4)](https://github.com/tkaratug "tkaratug (14 commits)")[![yidemir](https://avatars.githubusercontent.com/u/5863321?v=4)](https://github.com/yidemir "yidemir (1 commits)")

---

Tags

event-sourcingfinite-state-machinelaravellaravel-packageparallel-statesphpstate-machinexstatelaravelworkflowevent sourcingfsmfinite-state machinestate-machinexstate

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tarfin-labs-event-machine/health.svg)

```
[![Health](https://phpackages.com/badges/tarfin-labs-event-machine/health.svg)](https://phpackages.com/packages/tarfin-labs-event-machine)
```

###  Alternatives

[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[elegantly/laravel-translator

All on one translations management for Laravel

6333.1k](/packages/elegantly-laravel-translator)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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