Download the PHP package solidframe/event-sourcing without Composer
On this page you can find all versions of the php package solidframe/event-sourcing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download solidframe/event-sourcing
More information about solidframe/event-sourcing
Files in solidframe/event-sourcing
Package event-sourcing
Short Description Event Sourcing building blocks: EventStore, Snapshot, event-sourced AggregateRoot for SolidFrame
License MIT
Informations about the package event-sourcing
SolidFrame Event Sourcing
Event Sourcing building blocks: EventStore, Snapshot, and event-sourced AggregateRoot.
Store every state change as a domain event. Rebuild aggregate state by replaying events. Optimize with snapshots.
Installation
Quick Start
Define an Event-Sourced Aggregate
Persist and Load
Event Store
The EventStoreInterface defines how events are stored and loaded.
Concurrency Control
The event store uses optimistic locking. If another process has written events since you loaded, a ConcurrencyException is thrown:
In-Memory Store
For testing and prototyping:
Snapshots
Snapshots optimize loading for aggregates with many events.
Make an Aggregate Snapshotable
Snapshot Repository
Event Apply Convention
When replaying events, the aggregate calls apply{EventShortName}() automatically:
| Event Class | Apply Method |
|---|---|
OrderPlaced |
applyOrderPlaced() |
MoneyDeposited |
applyMoneyDeposited() |
AccountOpened |
applyAccountOpened() |
These methods are protected and must not be called directly.
API Reference
| Class / Interface | Purpose |
|---|---|
EventSourcedAggregateRootInterface |
Contract for event-sourced aggregates |
AbstractEventSourcedAggregateRoot |
Base aggregate with recordThat() and replay |
EventStoreInterface |
Event persistence contract |
InMemoryEventStore |
In-memory event store |
AggregateRootRepositoryInterface |
Aggregate persistence contract |
AggregateRootRepository |
Standard repository (full replay) |
SnapshotableAggregateRootInterface |
Contract for snapshotable aggregates |
Snapshot |
Snapshot value object |
SnapshotStoreInterface |
Snapshot persistence contract |
InMemorySnapshotStore |
In-memory snapshot store |
SnapshotAggregateRootRepository |
Repository with snapshot optimization |
AggregateNotFoundException |
Aggregate not found in event store |
ConcurrencyException |
Version conflict during persist |
Related Packages
- solidframe/core — DomainEventInterface, Identity
- solidframe/ddd — Entity, AggregateRoot base classes
- solidframe/cqrs — Command/Query handlers that use event-sourced aggregates
- solidframe/laravel — Database EventStore/SnapshotStore, migrations
- solidframe/symfony — DBAL EventStore/SnapshotStore, schema SQL
Contributing
This repository is a read-only split of the solidframe/solidframe monorepo, auto-synced on every push to main. Issues, pull requests, and discussions belong in the monorepo.