Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Event Sourcing

Event Sourcing Laravel Package

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.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Event Sourcing
How do I install and set up `dddominio/event-sourcing` in a Laravel 9+ project?
Run `composer require dddominio/event-sourcing ^1.0@dev` to install. The package integrates with Laravel’s service container, so no additional configuration is needed for basic usage. Follow the README’s aggregate setup guide to define your first event-sourced model. Ensure PHP 8.0+ and Laravel 9+ are installed, as the package relies on modern PHP features.
Does this package support Laravel’s Eloquent models, or do I need to rewrite existing models?
The package is designed for low-coupling integration. You can extend existing Eloquent models with event-sourcing behavior using traits or mixins. No full rewrite is required—start by applying it to new aggregates or incrementally migrate existing ones. The README provides examples for hybrid ORM/Event Sourcing setups.
What Laravel versions and PHP requirements does `dddominio/event-sourcing` support?
The package targets Laravel 9+ and PHP 8.0+ due to its reliance on modern PHP features like named arguments and attributes. Laravel 8.x may work with adjustments, but Laravel 5.x is unsupported. Check the repository’s `composer.json` for exact version constraints and compatibility notes.
Can I use this package for audit trails or compliance-heavy applications?
Yes, the package is explicitly built for auditability. It maintains an append-only event log, allowing you to replay events to reconstruct past states—ideal for financial systems, healthcare, or any domain requiring immutable records. Snapshotting further optimizes performance for large event histories.
How does event versioning work, and how do I handle backward compatibility?
The package includes built-in event versioning to manage schema evolution. When updating event structures, use backward-compatible changes (e.g., adding optional fields) and version your events. The library handles replaying events of different versions automatically, reducing migration risks. Refer to the documentation for versioning best practices.
What event stores are supported, and can I use EventStoreDB or Kafka?
The package supports Doctrine DBAL and MySQL JSON out of the box for database-backed event storage. While it doesn’t enforce a specific event store, you can integrate third-party stores like EventStoreDB or Kafka by implementing the package’s `EventStore` interface. The README includes examples for custom storage backends.
How do I handle projections (read models) without overloading the event stream?
Projections are a first-class feature in this package. You can define projections to materialize read models (e.g., for reporting) by subscribing to event streams. For large-scale systems, optimize projections with snapshotting or caching (e.g., Redis). The package provides tools to manage projection consistency and performance.
What are the performance implications of event sourcing compared to traditional ORM?
Event sourcing introduces write overhead due to appending events and replaying for state reconstruction. Benchmark your use case, as performance varies by workload. For read-heavy applications, use projections or snapshots to mitigate latency. The package includes tools to optimize query performance, but test thoroughly in your environment.
How do I test event-sourced aggregates, especially for historical state verification?
Testing event-sourced code requires replaying events to verify state changes. Use PHPUnit or Pest to mock event streams and assert aggregate states. For integration tests, spin up event stores with TestContainers or use in-memory stores. The package’s design simplifies testing by isolating aggregates and their event histories.
Are there alternatives to this package for Laravel event sourcing, and how does it compare?
Alternatives include `spatie/laravel-event-sourcing` (simpler but less feature-rich) and `prooph/event-store` (more generic but requires additional setup). This package stands out for its Laravel-native integration, DDD alignment, and built-in support for snapshotting and projections. Compare based on your need for auditability, CQRS, or microservices readiness.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
codifyo/ts-generator-bundle
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor