spatie/laravel-event-sourcing
Event sourcing toolkit for Laravel: build aggregates, projectors, and reactors to store state changes as events. Ideal for audit trails, decisions based on history, and future reporting needs. Includes docs, examples, and an optional course.
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.14.0...7.15.0
When registering projectors and reactors via class name strings, container resolution is now deferred until the handlers are actually needed. Most HTTP requests never fire a stored event, so the boot-time cost is never paid.
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.9...7.13.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.8...7.12.9
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.7...7.12.8
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.5...7.12.6
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.4...7.12.5
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.3...7.12.4
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.2...7.12.3
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.1...7.12.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.12.0...7.12.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.11.3...7.12.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.11.2...7.11.3
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.11.1...7.11.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.11.0...7.11.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.10.3...7.11.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.10.2...7.10.3
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.10.1...7.10.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.10.0...7.10.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.9.1...7.10.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.9.0...7.9.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.8.0...7.9.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.7.0...7.8.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.6.2...7.7.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.6.1...7.6.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.6.0...7.6.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.5.0...7.6.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.4.2...7.5.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.4.1...7.4.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.4.0...7.4.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.10...7.4.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.9...7.3.10
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.8...7.4.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.7...7.3.8
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.6...7.3.7
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.5...7.3.6
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.4...7.3.5
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.3...7.3.4
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.2...7.3.3
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.1...7.3.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.0...7.3.1
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.4...7.3.0
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.3...7.2.4
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.2...7.2.3
tap from possible handlers by @erikgaal in https://github.com/spatie/laravel-event-sourcing/pull/352Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.1...7.2.2
EloquentStoredEventQueryBuilder::lastEvent (#327)EloquentStoredEventQueryBuilder::wherePropertyIs (#326)EloquentStoredEventQueryBuilder::wherePropertyIsNot (#326)event_version to tinyint in migration stub (#306)FakeAggregateRoot::getRecordedEventsWithoutUuid (#296)jsonb in migration stubs instead of json (#237)event-sourcing:list command where event handlers wouldn't be shown$whenResult (#227)spatie/laravel-schemaless-attributes:^1.0 as wellAdd EloquentStoredEvent::query()->whereEvent(EventA::class, …)
Add EventQuery
Add AggregatePartial
parent::__construct from itAdd command bus and aggregate root handlers
Add Projectionist::fake(OriginalReactor::class, FakeReactor::class) (#181)
All event listeners are now registered in the same way: by looking at an event's type hint. This applies to all:
apply methodsMoved Spatie\EventSourcing\Exception\CouldNotPersistAggregate to Spatie\EventSourcing\AggregateRoots\Exceptions\CouldNotPersistAggregate
Moved Spatie\EventSourcing\Exception\InvalidEloquentSnapshotModel to Spatie\EventSourcing\AggregateRoots\Exceptions\InvalidEloquentSnapshotModel
Moved Spatie\EventSourcing\Exception\InvalidEloquentStoredEventModel to Spatie\EventSourcing\AggregateRoots\Exceptions\InvalidEloquentStoredEventModel
Moved Spatie\EventSourcing\Exception\MissingAggregateUuid to Spatie\EventSourcing\AggregateRoots\Exceptions\MissingAggregateUuid
Moved Spatie\EventSourcing\Exception\InvalidStoredEvent to Spatie\EventSourcing\StoredEvents\Exceptions\InvalidStoredEvent
Dependency injection in handlers isn't supported anymore, use constructor injection instead
$storedEvent and $aggregateRootUuid are no longer passed to event handler methods. Use $event->storedEventId() and $event->aggregateRootUuid() instead. (#180)
Rename EloquentStoredEvent::query()->uuid() to EloquentStoredEvent::query()->whereAggregateRoot()
Removed AggregateRoot::$allowConcurrency
Removed $aggregateVersion from StoredEventRepository::persist
Removed $aggregateVersion from StoredEventRepository::persistMany
Event handlers are no longer called with app()->call() (#180)
$handlesEvents on Projectors and Reactors isn't supported anymore
PHP version requirement is now ^8.0
Laravel version requirement is now ^8.0
Since most code is probably already type hinting events, the listener change is likely to not have an impact on your code. It's good to know though that you don't have to worry about certain naming conventions any more:
apply anymore if you don't want to$event$eventHere's an example:
class MyProjector extends Projector
{
public function anEventHandlerWithAnotherName(MyEvent $eventVariableWithAnotherName): void
{
// This handler will automatically handle `MyEvent`
}
}
Note that __invoke in projectors and reactors works the same way, it's automatically registered based on the type hinted event.
AggregateRoot::$allowConcurrencypublic function up()
{
Schema::table('stored_events', function (Blueprint $table) {
$table->unique(['aggregate_uuid', 'aggregate_version']);
});
}
Note: if you run this migration, all aggregate roots using $allowConcurrency will not work any more.
replay_chunk_size config valueShouldBeStored when possible (#158)loadUuid (#156)then for aggregate root fakes (#154)snapshot_model config keyShouldQueue marker interfaceShouldBeStored now can retrieve the aggregate root uuid using aggregateRootUuid()ShouldBeStored can now handle metadata using metaData and setMetaDatapersistWithoutApplyingToEventHandlershandleStoredEventspersistAggregateRootsInTransaction to AggregateRootuuid of an aggregate root using the uuid() methodreset method has been removed on projectorsfake method on an aggregate root now accepts a uuid instead of an array of eventsmeta_data property on StoredEvent is now an array or a string instead of SchemalessAttributesBigIncrements on package table stubs (#124)aggregate_version of StoredEvent (#115)app helper (#117)master
static return type docblock for AggregateRoot::retrievecreated_at is filled when creating a snapshotAggregateRoot for testing state (#75)basePath in DiscoversEventHandlers (#62)countAllStartingFromevent_properties when they're already a stringThis package supercedes spatie/laravel-event-projector
To learn how to upgrade from laravel-event-projector v3 to laravel-event-sourcing v1 , read our upgrade guide
EloquentStoredEvent import to example by @stevebauman in https://github.com/spatie/laravel-event-sourcing/pull/273Account model by @stevebauman in https://github.com/spatie/laravel-event-sourcing/pull/272Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/5.0.6...5.0.7
EventHandler interface was changed in order to use the spatie/better-types package:- public function handles(): array;
+ public function handles(StoredEvent $storedEvent): bool;
- public function handle(StoredEvent $event);
+ public function handle(StoredEvent $storedEvent): void;
How can I help you explore Laravel packages today?