All notable changes to laravel-event-sourcing
will be documented in this file:
- fix AggregateRoot return types for static analysis (#251)
- Use
jsonb
in migration stubs instead ofjson
(#237)
- Fix visual glitch in
event-sourcing:list
command where event handlers wouldn't be shown
- fix
$whenResult
(#227)
- Support legacy
spatie/laravel-schemaless-attributes:^1.0
as well
- move migrations to default location
-
Add
EloquentStoredEvent::query()->whereEvent(EventA::class, …)
-
Add
EventQuery
-
Add
AggregatePartial
- If you're overriding an aggregate root's constructor, make sure to call
parent::__construct
from it
- If you're overriding an aggregate root's constructor, make sure to call
-
Add 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:
- Aggregate root
apply
methods - Projection listeners
- Reactor listeners
- Event queries
- Aggregate root
-
Moved
Spatie\EventSourcing\Exception\CouldNotPersistAggregate
toSpatie\EventSourcing\AggregateRoots\Exceptions\CouldNotPersistAggregate
-
Moved
Spatie\EventSourcing\Exception\InvalidEloquentSnapshotModel
toSpatie\EventSourcing\AggregateRoots\Exceptions\InvalidEloquentSnapshotModel
-
Moved
Spatie\EventSourcing\Exception\InvalidEloquentStoredEventModel
toSpatie\EventSourcing\AggregateRoots\Exceptions\InvalidEloquentStoredEventModel
-
Moved
Spatie\EventSourcing\Exception\MissingAggregateUuid
toSpatie\EventSourcing\AggregateRoots\Exceptions\MissingAggregateUuid
-
Moved
Spatie\EventSourcing\Exception\InvalidStoredEvent
toSpatie\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()
toEloquentStoredEvent::query()->whereAggregateRoot()
-
Removed
AggregateRoot::$allowConcurrency
-
Removed
$aggregateVersion
fromStoredEventRepository::persist
-
Removed
$aggregateVersion
fromStoredEventRepository::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:
- In aggregate roots, you don't have to prefix apply methods with
apply
anymore if you don't want to - In projectors, you don't need a manual mapping anymore, neither does the event variable need to be called
$event
- In reactors, you don't need a manual mapping anymore, neither does the event variable need to be called
$event
- Event queries are a new concept and work in the same way
Here'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.
- Add missing config key in config stub (#203)
- Also store aggregate root version when one event is persisted
- Deprecate
AggregateRoot::$allowConcurrency
- Fix for race condition in aggregate roots (#170), you will need to run a migration to be able to use it:
public 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.
- Make base path configurable (#202)
- Add support for asserting events with a closure
- Fix for broken dependency in 4.7.1
- Fix for array serialization (#189)
- add support for PHP 8
- remove unused
replay_chunk_size
config value
- allow protected apply methods (#136)
- re-use existing instance of
ShouldBeStored
when possible (#158)
- fix Paths and Reference URL in event-sourcing.php config file (#159)
- added
loadUuid
(#156)
- make normalizers configurable (#153)
- Support
then
for aggregate root fakes (#154)
- Support Laravel 8
- support Carbon dates in events (#137)
- allow events to be dispatched from an aggregate root (#135)
- add assertion that specific event is recorded (#134)
- config style fix
- add
snapshot_model
config key
- projectors now are abstract classes instead of interfaces
- reactors can now be easily defined by extending the reactor base class
- projectors and reactors can be marked as async by implementing the
ShouldQueue
marker interface - events that extend
ShouldBeStored
now can retrieve the aggregate root uuid usingaggregateRootUuid()
- the package has been restructured. Namespaces of most classes have been updated.
- events that extend
ShouldBeStored
can now handle metadata usingmetaData
andsetMetaData
- aggregate roots can now be persisted without calling event handlers using
persistWithoutApplyingToEventHandlers
- the projectionist can now handle manually specified events using
handleStoredEvents
- added
persistAggregateRootsInTransaction
toAggregateRoot
- you can now get the
uuid
of an aggregate root using theuuid()
method - the
reset
method has been removed on projectors - the
fake
method on an aggregate root now accepts a uuid instead of an array of events - the
meta_data
property onStoredEvent
is now an array or a string instead ofSchemalessAttributes
- apply methods on aggregates can now make use of method injection
- pass metadata to serializer to allow events to be upgraded (#112)
- default to
BigIncrements
on package table stubs (#124)
- replace model where clause with uuid model scope (#123)
- config file comment corrections (#121)
- expose
aggregate_version
ofStoredEvent
(#115)
- use
app
helper (#117)
master
- allow aggregate roots to have dependencies in constructor (#111)
- wrong tag, nothing changed
- only include public properties of the aggregate when snapshotting (#105)
- simplify snapshot dates
- add
static
return type docblock forAggregateRoot::retrieve
- make sure
created_at
is filled when creating a snapshot
- expose
AggregateRoot
for testing state (#75)
- add support for Laravel 7
- fix for serializing events that use immutable datetime objects (#67)
- fixes for Lumen
- only replace the first instance of the
basePath
inDiscoversEventHandlers
(#62)
- publish snapshots migration
- add the ability to snapshot aggregates
- make all classes non-final
- do not allow concurrent persist on an aggregate by default
- add
countAllStartingFrom
- do not dispatch job when there is nothing to be performed on queue
- drop PHP 7.3
- fix replay from specified event id (#33)
- provide docblocks to AggregateRoot class (#31)
- implemented missing HandleDomainEventJob interface
- use a UUID field when possible for storing UUIDs
- fix an issue with encoding the
event_properties
when they're already a string
- initial release
This 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