Getting started withevent sourcing in Laravel
View Slide
About meFreek Van der HertenPartner & developer at Spatie@freekmurzemurze.beohdear.app
SpatieLaravel, front-end developmentSince 20039 awesome human beings
Open Source Software
We create a lot of it± 200 packages on Packagist± 2,000,000 downloads a month± 30,000,000 total downloadsAll Postcardware!
HighlightsPopularlaravel-backuplaravel-medialibrarylaravel-permissionNewlaravel-query-builderlaravel-blade-x
https://spatie.be/open-source
https://spatie.be/open-source/postcards
Let's talk aboutevent sourcing
Talk overviewTheoryProjectors demoAggregates demo
Theory
Traditional applicationWrite data in databaseAn update means overwriting the old dataThe old data cannot be accessed anymore
APPLICATIONDATABASETABLEvalue X
APPLICATIONDATABASETABLEvalue Xvalue Y
Event Sourced ApplicationThe application will fire off eventsEvents will get written in a dedicated storeEvents are passed to consumers that create projectionsAggregate, Aggregate Root...
APP EVENTSEventEvent 1
APP EVENTSEventEvent 1Event 2
APP EVENTSEventEvent 1Event 2Event 3
APPCONSUMEREVENTSPROJECTIONEventEvent 1Event 2Event 3
APPCONSUMERCONSUMER 2EVENTSPROJECTIONEventEvent 1Event 2Event 3ANOTHER PROJECTION
APPCONSUMERCONSUMER 2EVENTSPROJECTIONEventEvent 1Event 2Event 3Event 4ANOTHER PROJECTION
Event Sourced ApplicationAuditing requirementsExtra reports neededRecording the unhappy pathThere is some setup required
Laravel Event Projector
Laravel Event ProjectorPackage made by SpatieAggregates, Projectors & ReactorsBeautifully integrated into LaravelEasy to get started with
https://docs.spatie.be/laravel-event-projector
Demo
Aggregates
In closing
SummaryLaravel Event ProjectorEasy to use package to get started with event sourcingProjectorsReplay capabilitiesAggregates
Writes are harder, reads are easier
Event sourcing makes the easy things harder……and the harder things easier— Frank De Jonge
Larabankgithub.com/spatie/larabank-traditionalgithub.com/spatie/larabank-event-projectorgithub.com/spatie/larabank-event-projector-aggregatesgithub.com/spatie/larabank-eventsauce
Resourceskickstarter.engineering/event-sourcing-made-simple-4a2625113224github.com/spatie/laravel-event-projectorgithub.com/eventsaucephp/eventsaucegithub.com/prooph
Thank you!speakerdeck.com/freekmurze/event-sourcing-full-stack-ghentspatie.be/open-sourcemurze.beohdear.app