Event Sourcing Core
domainflow/event-sourcing-core is a persistence-agnostic PHP library for
building event-sourced domains. It provides the domain and application seams;
it does not depend on a database, queue, or framework.
The package includes:
- aggregate roots that rebuild their state by replaying events;
- aggregate repository and facade, exposed through
EventSourcingFacade; - storage contracts and in-memory reference implementations;
- optimistic concurrency checking;
- snapshots and snapshot history;
- event dispatching, projectors, and replay operations;
- outbox delivery primitives;
- event-driven process managers with persisted state and timeouts;
- event type names, payload schema evolution, and upcasting;
- optional event metadata and crypto-shredding for marked personal data.
The package defines contracts for infrastructure. A database adapter implements those contracts and is documented separately from this core package.
Requirements
- PHP 8.4 or newer
- the Sodium PHP extension (
ext-sodium) domainflow/uuid
Where to start
- Install the package.
- Follow the quickstart to define an aggregate and persist it.
- Read events and aggregates for the replay model.
- Implement or select a storage adapter using the storage contracts.
The operational topics are covered in projections and dispatch, snapshots, outbox delivery, and process managers.