All notable changes to laravel-event-sourcing
will be documented in this file:
- update command name to match class name by @PH7-Jack in #490
- @PH7-Jack made their first contribution in #490
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.9.0...7.9.1
- Use class map name when querying event class by @maartenpaauw in #476
- Register optimize commands by @erikgaal in #489
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.8.0...7.9.0
- Replace 'projector' with 'reactor' where necessary. by @PHPGuus in #485
- Only Dispatch If Event Has Async Handler by @damiantw in #484
- @PHPGuus made their first contribution in #485
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.7.0...7.8.0
- Update installation-setup.md to match actual contents of config/event-sourcing.php by @inmanturbo in #473
- add force option to replay command by @inmanturbo in #474
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.6.2...7.7.0
- fix: internal links use /docs prefix by @rburgt in #468
- Add reflection exception error message to InvalidStoredEvent exception by @deonvdv in #469
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.6.1...7.6.2
- Use custom serializer while persisting events by @sebastiandittrich in #464
- @sebastiandittrich made their first contribution in #464
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.6.0...7.6.1
- Pass specified aggregate uuid to resetState while replaying by @meijdenmedia in #463
- @meijdenmedia made their first contribution in #463
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.5.0...7.6.0
- Add config to enforce every event has an alias. by @thettler in #461
- @thettler made their first contribution in #461
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.4.2...7.5.0
- fix AllowDynamicProperties to suppress PHP warnings on 8.2
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.4.1...7.4.2
- AllowDynamicProperties to suppress PHP warnings on 8.2 by @sebastiandedeyne in #459
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.4.0...7.4.1
- L11 compatibility by @inmanturbo in #458
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.10...7.4.0
- Address Typos and Make Grammatical Improvements in Documentation by @salehhashemi1992 in #442
- Update actions/checkout to v4 by @salehhashemi1992 in #441
- Fix Some Typos in Method Names, Namespaces, and PHPDoc Annotations by @salehhashemi1992 in #443
- Document prepare events using abstract class instead of interface by @Sparclex in #446
- Change the column type of snapshots.aggregate_version by @eschalks in #447
- @salehhashemi1992 made their first contribution in #442
- @Sparclex made their first contribution in #446
- @eschalks made their first contribution in #447
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.9...7.3.10
- Fix snapshots in aggregate partials by @sonja-turo in #406
- Ignore abstract event handlers by @27pchrisl in #430
- @sonja-turo made their first contribution in #406
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.8...7.4.0
- Added an extra rejection to prevent events being passed to invalid handlers by @27pchrisl in #438
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.7...7.3.8
- Support interfaces in aggregate root apply methods by @sebastiandedeyne in #434
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.6...7.3.7
- Correcting Commands Documentation by @ChangingTerry in #416
- Sort projectors by weight when replaying by @rapkis in #425
- Replay events with custom stored event model by @avosalmon in #410
- Corrects typos in docs by @DriverCat in #429
- Make the aggregatePartial recordThat method fluent by @maartenpaauw in #433
- @ChangingTerry made their first contribution in #416
- @DriverCat made their first contribution in #429
- @maartenpaauw made their first contribution in #433
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.5...7.3.6
- Document the use of the Projection class by @27pchrisl in #409
- Expand documentation for projection factories by @Ahrengot in #413
- Fix Symfony Serializer Deprecation Warnings by @damiantw in #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 #402
- Fix README.md version cross-linking to other versions for v7. #396 by @Shkeats in #403
- Fix preserving event order when dispatched from aggregate root via event handler by @daniser in #405
- @Shkeats made their first contribution in #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 #391
- @laravel-shift made their first contribution in #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 #384
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/7.3.1...7.3.2
- Refactor tests to pest by @AyoobMH in #377
- Add PHP 8.2 Support by @patinthehat in #379
- update document by @godkinmo in #380
- Use the snapshot with the highest ID by @27pchrisl in #381
- @AyoobMH made their first contribution in #377
- @patinthehat made their first contribution in #379
- @godkinmo made their first contribution in #380
- @27pchrisl made their first contribution in #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 #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 #363
- Update event-sourcing:replay command to work with just one aggregate uuid by @soarecostin in #362
- @soarecostin made their first contribution in #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 #353
- Update AggregateRoot::apply() to utilize acceptsTypes() function by @zackrowe in #354
- @michael-rubel made their first contribution in #353
- @zackrowe made their first contribution in #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 #350
- Exclude
tap
from possible handlers by @erikgaal in #352
- @daniser made their first contribution in #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 #328
- Update cache_path in config by @lloricode in #329
- Update Projector docs to reflect changes to getting the aggregate uuid by @RobHarveyDev in #331
- Docs: createdAt() method is camel case by @inmanturbo in #332
- Update migration file to closure by @lloricode in #330
- Fix link to "getting familiar section" by @felixfrey in #343
- Do not assert events given to FakeAggregateRoot as recorded by @itsmarsu in #344
- @lloricode made their first contribution in #329
- @RobHarveyDev made their first contribution in #331
- @inmanturbo made their first contribution in #332
- @felixfrey made their first contribution in #343
- @itsmarsu made their first contribution in #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 #326
- Adds last event helper by @aidan-casey in #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 #314
- Updated the requirement to Laravel 9 by @davidlapham in #318
- Resolves issue with meta data updating on original event. by @aidan-casey in #324
- @rmcdaniel made their first contribution in #314
- @davidlapham made their first contribution in #318
- @aidan-casey made their first contribution in #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 #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 #286
- Set minimum version of illuminate/database to ^8.34 by @etahamer in #290
Full Changelog: https://github.com/spatie/laravel-event-sourcing/compare/5.0.7...5.0.8
- Update introduction.md by @WouterBrouwers in #266
- Update installation-setup.md by @WouterBrouwers in #265
- Update introduction.md by @WouterBrouwers in #264
- Update using-projectors-to-transform-events.md by @WouterBrouwers in #263
- Update using-aggregates-to-make-decisions-based-on-the-past.md by @WouterBrouwers in #262
- Update creating-and-configuring-projectors.md by @WouterBrouwers in #261
- Update thinking-in-events.md by @WouterBrouwers in #260
- Update writing-your-first-reactor.md by @WouterBrouwers in #259
- Update writing-your-first-aggregate.md by @WouterBrouwers in #258
- Update replaying-events.md by @WouterBrouwers in #257
- Update storing-metadata.md by @WouterBrouwers in #256
- fix broken link to the course by @macbookandrew in #253
- Fix urls pointing to previous version by @quintenbuis in #269
- [Docs] Add
EloquentStoredEvent
import to example by @stevebauman in #273 - [Docs] Add missing opening bracket for
Account
model by @stevebauman in #272 - [Docs] Fix wrong operator for onMoneySubtracted by @avosalmon in #279
- Changed cursor() into lazyById() to preserve memory when working with large amount of events by @etahamer in #284
- @WouterBrouwers made their first contribution in #266
- @macbookandrew made their first contribution in #253
- @quintenbuis made their first contribution in #269
- @stevebauman made their first contribution in #273
- @avosalmon made their first contribution in #279
- @etahamer made their first contribution in #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