spatie/laravel-event-projector
Deprecated in favor of spatie/laravel-event-sourcing. Entry-level event sourcing toolkit for Laravel: define aggregates, projectors, and reactors; persist domain events, build read models, and react to events for auditing and reporting-friendly apps.
spatie/laravel-event-sourcing (successor package), ensuring long-term viability.Adopt When:
Look Elsewhere If:
spatie/laravel-event-sourcing (v1+)."This package lets us build systems where every change is recorded as an immutable event—like a blockchain for our business logic. For example, in [Use Case X], we can instantly reconstruct any past state of a critical record (e.g., a financial transaction) or trigger real-time updates to dashboards without manual syncs. It’s like adding a time machine to our data, reducing errors and enabling features like ‘undo’ or ‘roll back’ for high-stakes actions. The trade-off? A modest upfront investment in rethinking how we model data, but long-term gains in reliability and scalability. Oh, and it’s built for Laravel, so our existing team can adopt it quickly."
Key Outcomes:
*"This is a battle-tested way to implement event sourcing in Laravel with minimal boilerplate. Here’s why it’s a no-brainer:
UserAggregate emits UserRegistered, EmailVerified events).UserProfile table) from events via SQL queries.UserRegistered fires) with decoupled logic.Migration Path: The package is archived but trivial to upgrade to spatie/laravel-event-sourcing. We’d start with a spike to validate:
Alternatives: If we need more than SQL projections or active maintenance, we’d evaluate Laravel Serenity or build a custom solution—but this gives us 80% of the value with 20% of the effort."*
Tech Deep Dive:
// Define an aggregate
class UserAggregate {
public function register(string $email) {
$this->recordThat(new UserRegistered($email));
}
}
// Project to a read model
class UserProfileProjector {
public function onUserRegistered(UserRegistered $event) {
UserProfile::create([...]);
}
}
Call to Action:
How can I help you explore Laravel packages today?