PHPackages                             milpa/event-store - 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. [Database &amp; ORM](/categories/database)
4. /
5. milpa/event-store

ActiveLibrary[Database &amp; ORM](/categories/database)

milpa/event-store
=================

Append-only event-log primitive for the Milpa PHP framework: durable JSONL file store and in-memory store behind a common EventStoreInterface — per-stream replay and store-wide monotonic sequencing.

v0.1.0(1mo ago)01.4k4Apache-2.0PHPPHP &gt;=8.3CI passing

Since Jul 9Pushed 6d agoCompare

[ Source](https://github.com/getmilpa/event-store)[ Packagist](https://packagist.org/packages/milpa/event-store)[ RSS](/packages/milpa-event-store/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (5)Versions (2)Used By (4)

 [   ![Milpa](https://raw.githubusercontent.com/getmilpa/core/main/art/lockup/milpa-lockup-v-color-light.svg)  ](https://github.com/getmilpa)

Milpa Event Store
=================

[](#milpa-event-store)

> A tiny **append-only event log** for the Milpa PHP framework, with **zero package dependencies**. Append events, replay a stream, project state from the fold. Two interchangeable stores — **file** (JSONL) and **in-memory** — behind one `EventStoreInterface`. The persistence primitive under Milpa's event-sourced process engine.

[![CI](https://github.com/getmilpa/event-store/actions/workflows/ci.yml/badge.svg)](https://github.com/getmilpa/event-store/actions/workflows/ci.yml)[![Packagist](https://camo.githubusercontent.com/c74a622de7cc52dfb7a5bd7d3d166e581d57dca740a9d98d295cff7579883855/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d696c70612f6576656e742d73746f72652e737667)](https://packagist.org/packages/milpa/event-store)[![PHP](https://camo.githubusercontent.com/ca03f11ea27dac4dedc8ad56a7bdfc4a9ff5feb825055f9d2983616115076607/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230382e332d3737376262342e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/798509b4df525f56802b56f8096862487f08023e3d7561c68656f8dab10d0d6e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4170616368652d2d322e302d626c75652e737667)](LICENSE)[![Docs](https://camo.githubusercontent.com/c6dc6a3411e15b0ac7cc4583e8e6a8144181caedb82f5d98753353decda06d77/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63732d4150492532307265666572656e63652d626c75652e737667)](https://getmilpa.github.io/event-store/)

`milpa/event-store` is the smallest possible seam onto an append-only log: an `Event` is an immutable fact — `streamId`, `type`, `payload`, `seq`, `recordedAt` — and a store's only two jobs are "append durably" and "read a stream back in order". **No ORM, no serializer, no framework coupling** — construct a store with a path (or nothing at all) and call `append()`.

`recordedAt` is a UTC-serialized wall-clock observation made by the process constructing a new event. It says when that process's clock observed the record, not when the domain event objectively happened, and it is no more trustworthy than that process and clock. Legacy records replay with `recordedAt === null`; the store never invents their time from filenames, file metadata, or payloads.

Install
-------

[](#install)

```
composer require milpa/event-store
```

Quick example
-------------

[](#quick-example)

```
use Milpa\EventStore\Event;
use Milpa\EventStore\FileEventStore;

$store = new FileEventStore('/var/data/orders.jsonl');

// Append: nextSeq() hands out the store-wide monotonic counter, one call per event.
$store->append(new Event('order-42', 'OrderPlaced', ['total' => 19.99], $store->nextSeq()));
$store->append(new Event('order-42', 'OrderShipped', ['carrier' => 'DHL'], $store->nextSeq()));

// Replay: every event for one stream, in ascending seq order — never other streams' events.
foreach ($store->replay('order-42') as $event) {
    printf("#%d %s %s\n", $event->seq, $event->type, json_encode($event->payload));
}
// #1 OrderPlaced {"total":19.99}
// #2 OrderShipped {"carrier":"DHL"}

$store->streams();  // ["order-42"]
$store->nextSeq();  // 3 — one past the highest seq in the store, across every stream
```

Project current state by folding the replayed events yourself — the store never stores state, only the facts it was told:

```
$state = array_reduce(
    $store->replay('order-42'),
    static fn (array $state, Event $event): array => match ($event->type) {
        'OrderPlaced' => [...$state, 'status' => 'placed', 'total' => $event->payload['total']],
        'OrderShipped' => [...$state, 'status' => 'shipped', 'carrier' => $event->payload['carrier']],
        default => $state,
    },
    [],
);
// ['status' => 'shipped', 'total' => 19.99, 'carrier' => 'DHL']
```

Two stores, one interface
-------------------------

[](#two-stores-one-interface)

StoreDurabilityUse it for`FileEventStore`Appends one JSON line per event to a flat file, under an exclusive `flock()` so concurrent appenders never interleave partial lines. `nextSeq()` and `replay()` both re-derive their answer from the file itself — a fresh instance pointed at the same path, in a different process or a different request, agrees with every other instance about both "what happened" and "what comes next".Real persistence — the process engine's durable log.`InMemoryEventStore`An in-process array. Nothing is written to disk; nothing survives past the instance's lifetime.Tests, and zero-file consumers that don't need durability.Both implement the same four-method `EventStoreInterface` (`append()`, `replay()`, `nextSeq()`, `streams()`), verified by one shared contract test suite (`EventStoreContractTestCase`) so behavior — sequencing, stream isolation, replay order — never drifts between the two.

Requirements
------------

[](#requirements)

- PHP **≥ 8.3**
- Nothing else — `milpa/event-store` has no package dependencies, Milpa or otherwise

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

[](#documentation)

**Full API reference: [getmilpa.github.io/event-store](https://getmilpa.github.io/event-store/)** — generated straight from the source DocBlocks and dressed with the Milpa design system.

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

[](#contributing)

Contributions are welcome — see [CONTRIBUTING.md](CONTRIBUTING.md). Please report security issues via [SECURITY.md](SECURITY.md), and note that this project follows a [Code of Conduct](CODE_OF_CONDUCT.md).

License
-------

[](#license)

[Apache-2.0](LICENSE) © Rodrigo Vicente - TeamX Agency.

---

Milpa is designed, built, and maintained by **[Rodrigo Vicente - TeamX Agency](https://teamx.agency/?utm_source=github&utm_medium=readme&utm_campaign=milpa&utm_content=event-store)**.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 83.3% 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

Unknown

Total

1

Last Release

48d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1993784?v=4)[rodrigomx](/maintainers/rodrigomx)[@rodrigomx](https://github.com/rodrigomx)

---

Top Contributors

[![rodrigoteamx](https://avatars.githubusercontent.com/u/269849276?v=4)](https://github.com/rodrigoteamx "rodrigoteamx (15 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

append-onlyappend-only-logevent-sourcingevent-storeframeworkjsonlmilpaphp

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/milpa-event-store/health.svg)

```
[![Health](https://phpackages.com/badges/milpa-event-store/health.svg)](https://phpackages.com/packages/milpa-event-store)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[ichikaway/cakephp-mongodb

MongoDB Datasource for CakePHP

3388.2k](/packages/ichikaway-cakephp-mongodb)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)

PHPackages © 2026

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