This is the documentation for
You can switch versions in the menu on the left/at the top.
Check your current version with the following command:
composer show spatie/laravel-event-sourcing
The package will listen for events that implement the
\Spatie\EventSourcing\ShouldBeStored interface. This is an empty interface that simply signals to the package that the event should be stored.
You can quickly create an event that implements
ShouldBeStored by running this artisan command:
php artisan make:storable-event NameOfYourEvent
Here's an example of such event:
class MoneyAdded extends ShouldBeStored
/** @var string */
/** @var int */
public function __construct(string $accountUuid, int $amount)
$this->accountUuid = $accountUuid;
$this->amount = $amount;
Whenever an event that implements
ShouldBeStored is fired it will be serialized and written in the
stored_events table. Immediately after that, the event will be passed to all projectors and reactors.
##Specifying a queue
StoredEvent is created, we'll dispatch a job on the queue defined in the
queue key of the
event-sourcing config file. Queued projectors and reactors will get called when the job is executed on the queue.
On an event you can override the queue that should be used by adding a
class MyEvent extends ShouldBeStored
public $queue = 'alternativeQueue';