Download the PHP package domainflow/event-sourcing-core without Composer
On this page you can find all versions of the php package domainflow/event-sourcing-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download domainflow/event-sourcing-core
More information about domainflow/event-sourcing-core
Files in domainflow/event-sourcing-core
Package event-sourcing-core
Short Description A PHP event sourcing library with aggregates, events, snapshots, event upcasting, projections, and more.
License MIT
Informations about the package event-sourcing-core
DomainFlow EventSourcing Core
A persistence-agnostic PHP event sourcing library: aggregates, events, snapshots, optimistic concurrency, event upcasting, projections, and process managers. It defines the storage seams a concrete database technology implements — it never depends on a concrete database or framework itself.
Requirements
- PHP 8.4+
- Sodium PHP extension
ext-sodium - DomainFlow Uuid Package
domainflow/uuid
Installation
Core concepts
- Aggregate root —
AggregateRoot, a domain object whose state is derived by replaying its own event history. Extend it, implementapply<EventShortName>()handler methods and thenewInstance(): staticfactory method. - Domain event —
DomainEventInterface, or extend theSourceEventbase class for the common boilerplate (aggregate ID, event ID, version, occurred-on timestamp). - Aggregate repository / facade —
AggregateRepositoryis the load/save orchestrator;EventSourcingFacadeis the intended single public entry point most consumers use, wrapping the repository plus optional concurrency checking, snapshotting, and event dispatch. - Crypto-shredding —
#[PersonalData]on a field,#[DataSubjectId]on the one that says whose it is, and erasure is destroying that subject's key: the event stays exactly as written and stops being readable. It is a decorator around the entry factory, so no storage adapter is involved. After erasure the field readsRedactedValue::MARKERrather than null, so a projector can tell "erased" from "never set". - Operational commands —
Operation\DrainOutbox,Operation\RebuildProjectionandOperation\EnsureSchema: the three things that have to be run in production, as plain invokables that return a result and log nothing. No console dependency here, so bind them to whatever CLI you have.DrainOutboxis the relay loop with the parts that are easy to get wrong — back-off on an idle pass and none on a busy one,maxPasses/maxSecondsso the same object serves cron and a daemon, and astop()flag read between passes so aSIGTERMnever drops the entries the current pass claimed. - Storage interfaces —
EventStorageInterface,SnapshotStorageInterface,SnapshotHistoryStorageInterface,ProcessManagerStorageInterface. Implement these against a concrete database to build a new storage adapter. - Process manager —
AbstractProcessManagerfor event-driven sagas: implementsProcessManagerInterfaceandEventSubscriberInterface, so a single instance can register directly withEventDispatcher. Saga timeouts fire fromProcessManagerTimeoutRunner, which you schedule the same way you scheduleOutboxRelay— a timeout exists for the case where no event is arriving, so nothing else is going to look at the process again.
Usage
Building your own storage adapter
provider/Unit/ and provider/Integration/ ship as production code (not dev-only) specifically so an adapter package can composer require this package and reuse these abstract PHPUnit test cases to prove its concrete storage classes satisfy the same contract this library's own InMemory* reference adapters do.
Development
License
MIT — see LICENSE.