dddominio/event-sourcing
Laravel package for event sourcing in DDD-style apps. Store and replay domain events to rebuild aggregates, keep an append-only event log, and track state changes over time. Useful for audit trails, projections, and CQRS-inspired architectures.
| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Event Schema Evolution | High | Adopt backward-compatible event versioning. |
| Performance Overhead | Medium | Benchmark write/read latency vs. traditional ORM. |
| Debugging Complexity | High | Implement event replay tools and snapshotting. |
| State Reconstruction | Medium | Optimize projection queries (e.g., materialized views). |
| Team Adoption | Medium | Conduct spike projects to validate ROI. |
Order and Payment be separate aggregates, or merged into OrderAggregate?Model with ES behavior via traits/mixins.| Phase | Scope | Tools/Techniques |
|---|---|---|
| Assessment | Audit existing domain models. | Draw aggregate diagrams, identify ES candidates. |
| Spike | Prove ES viability. | Implement one aggregate (e.g., Invoice). |
| Hybrid Mode | Dual-write (ORM + ES). | Use Laravel observers to sync events. |
| Full Adoption | Replace ORM for new features. | Migrate one module at a time. |
| Optimization | Tune projections, snapshots. | Benchmark query performance. |
pdo_pgsql/pdo_mysql for DB storage.redis extension if caching projections.Event class conflicts with Laravel’s Event facade).UserDashboardProjection).| Issue Type | Resolution Path |
|---|---|
| Event handler failure | Check event store for duplicates. |
| Slow queries | Optimize projections or use snapshots. |
| State inconsistency | Replay events from known-good state. |
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Event store outage | No new events processed. | Queue buffering + retries. |
| Projection failure | Stale read models. | Dead-letter queues for reprocessing. |
| Aggregate corruption | Invalid state. | Snapshots + replay from backup. |
| Network partition (distributed) | Event loss. | Idempotent handlers + logging. |
| Schema migration failure | Event deserialization errors. | Backward-compatible event versions. |
BlogPost).How can I help you explore Laravel packages today?