All notable changes to laravel-event-sourcing
will be documented in this file:
- Document the use of the Projection class by @27pchrisl in spatie#409
- Expand documentation for projection factories by @Ahrengot in spatie#413
- Fix Symfony Serializer Deprecation Warnings by @damiantw in spatie#415
- @Ahrengot made their first contribution in spatie#413
- @damiantw made their first contribution in spatie#415
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.4...7.3.5
- Fix documentation version cross-linking to other versions for v7. #396 by @Shkeats in spatie#402
- Fix README.md version cross-linking to other versions for v7. #396 by @Shkeats in spatie#403
- Fix preserving event order when dispatched from aggregate root via event handler by @daniser in spatie#405
- @Shkeats made their first contribution in spatie#402
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.3...7.3.4
- Laravel 10.x Compatibility by @laravel-shift in spatie#391
- @laravel-shift made their first contribution in spatie#391
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.2...7.3.3
- Fixes bug with retrieving last event by @aidan-casey in spatie#384
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.1...7.3.2
- Refactor tests to pest by @AyoobMH in spatie#377
- Add PHP 8.2 Support by @patinthehat in spatie#379
- update document by @godkinmo in spatie#380
- Use the snapshot with the highest ID by @27pchrisl in spatie#381
- @AyoobMH made their first contribution in spatie#377
- @patinthehat made their first contribution in spatie#379
- @godkinmo made their first contribution in spatie#380
- @27pchrisl made their first contribution in spatie#381
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.0...7.3.1
- Support weight property to event handlers by @sebastiandedeyne in spatie#365
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.4...7.3.0
- Update Reactor docs on how to get the aggregate uuid by @soarecostin in spatie#363
- Update event-sourcing:replay command to work with just one aggregate uuid by @soarecostin in spatie#362
- @soarecostin made their first contribution in spatie#363
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.3...7.2.4
- Fix typo in ReadMe by @michael-rubel in spatie#353
- Update AggregateRoot::apply() to utilize acceptsTypes() function by @zackrowe in spatie#354
- @michael-rubel made their first contribution in spatie#353
- @zackrowe made their first contribution in spatie#354
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.2...7.2.3
- Fix method annotations in Projection class by @daniser in spatie#350
- Exclude
tap
from possible handlers by @erikgaal in spatie#352
- @daniser made their first contribution in spatie#350
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.1...7.2.2
- Fix URL to documentation about caching by @rodrigopedra in spatie#328
- Update cache_path in config by @lloricode in spatie#329
- Update Projector docs to reflect changes to getting the aggregate uuid by @RobHarveyDev in spatie#331
- Docs: createdAt() method is camel case by @inmanturbo in spatie#332
- Update migration file to closure by @lloricode in spatie#330
- Fix link to "getting familiar section" by @felixfrey in spatie#343
- Do not assert events given to FakeAggregateRoot as recorded by @itsmarsu in spatie#344
- @lloricode made their first contribution in spatie#329
- @RobHarveyDev made their first contribution in spatie#331
- @inmanturbo made their first contribution in spatie#332
- @felixfrey made their first contribution in spatie#343
- @itsmarsu made their first contribution in spatie#344
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.2.0...7.2.1
- Adds query helpers for event properties by @aidan-casey in spatie#326
- Adds last event helper by @aidan-casey in spatie#327
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.0.1...7.2.0
- Add
EloquentStoredEventQueryBuilder::lastEvent
(#327) - Add
EloquentStoredEventQueryBuilder::wherePropertyIs
(#326) - Add
EloquentStoredEventQueryBuilder::wherePropertyIsNot
(#326)
- Update testing-aggregates.md by @rmcdaniel in spatie#314
- Updated the requirement to Laravel 9 by @davidlapham in spatie#318
- Resolves issue with meta data updating on original event. by @aidan-casey in spatie#324
- @rmcdaniel made their first contribution in spatie#314
- @davidlapham made their first contribution in spatie#318
- @aidan-casey made their first contribution in spatie#324
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.0.0...7.0.1
- Fix for meta data updating on original event (#324)
- Change
event_version
totinyint
in migration stub (#306)
- Don't mutate original events in
FakeAggregateRoot::getRecordedEventsWithoutUuid
(#296)
- downgrade symfony finder by @morrislaptop in spatie#295
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/6.0.2...6.0.3
- Skip retrieve on aggregate::fake (#294)
- Skip retrieve on aggregate::fake (#294)
- Fix for aggregate root testing without a database (#292)
- Support PHP 8.1
- The
EventHandler
interface was changed in order to use thespatie/better-types
package:
- public function handles(): array;
+ public function handles(StoredEvent $storedEvent): bool;
- public function handle(StoredEvent $event);
+ public function handle(StoredEvent $storedEvent): void;
- Support PHP 8.1
- The
EventHandler
interface was changed in order to use thespatie/better-types
package:
- public function handles(): array;
+ public function handles(StoredEvent $storedEvent): bool;
- public function handle(StoredEvent $event);
+ public function handle(StoredEvent $storedEvent): void;
- Fixed tests/VersionedEventTest.php::a_versioned_event_can_be_restored by @etahamer in spatie#286
- Set minimum version of illuminate/database to ^8.34 by @etahamer in spatie#290
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/5.0.7...5.0.8
- Update introduction.md by @WouterBrouwers in spatie#266
- Update installation-setup.md by @WouterBrouwers in spatie#265
- Update introduction.md by @WouterBrouwers in spatie#264
- Update using-projectors-to-transform-events.md by @WouterBrouwers in spatie#263
- Update using-aggregates-to-make-decisions-based-on-the-past.md by @WouterBrouwers in spatie#262
- Update creating-and-configuring-projectors.md by @WouterBrouwers in spatie#261
- Update thinking-in-events.md by @WouterBrouwers in spatie#260
- Update writing-your-first-reactor.md by @WouterBrouwers in spatie#259
- Update writing-your-first-aggregate.md by @WouterBrouwers in spatie#258
- Update replaying-events.md by @WouterBrouwers in spatie#257
- Update storing-metadata.md by @WouterBrouwers in spatie#256
- fix broken link to the course by @macbookandrew in spatie#253
- Fix urls pointing to previous version by @quintenbuis in spatie#269
- [Docs] Add
EloquentStoredEvent
import to example by @stevebauman in spatie#273 - [Docs] Add missing opening bracket for
Account
model by @stevebauman in spatie#272 - [Docs] Fix wrong operator for onMoneySubtracted by @avosalmon in spatie#279
- Changed cursor() into lazyById() to preserve memory when working with large amount of events by @etahamer in spatie#284
- @WouterBrouwers made their first contribution in spatie#266
- @macbookandrew made their first contribution in spatie#253
- @quintenbuis made their first contribution in spatie#269
- @stevebauman made their first contribution in spatie#273
- @avosalmon made their first contribution in spatie#279
- @etahamer made their first contribution in spatie#284
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/5.0.6...5.0.7
- 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
- Aggregate root
-
- Projection listeners
-
- Reactor listeners
-
- Event queries
- 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