Skip to main content

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

  1. Install the package.
  2. Follow the quickstart to define an aggregate and persist it.
  3. Read events and aggregates for the replay model.
  4. 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.