Projecting eventsin Laravel
View Slide
About meFreek Van der HertenPartner & developer at Spatie@freekmurzehttps://murze.behttps://ohdear.app
SpatieSince 2003Websites, applications and webshopsTeam9 awesome human beingsSpecialisationLaravel, front-end development
Open Source Software
We create a lot of it± 200 packages on Packagist± 2,000,000 downloads a month± 25,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 aboutprojecting events
Talk overviewTheoryLaravel Event Projector demo
Theory
Traditional applicationWrite data in databaseAn update means overwriting the old dataThe old data cannot be accessed anymore
APPLICATIONDATABASETABLEvalue X
APPLICATIONDATABASETABLEvalue Xvalue Y
Using projectorsThe application will fire off eventsEvents will get written in a dedicated storeEvents are passed to classes that can handle them
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
Projecting eventsAuditing requirementsExtra reports neededThere is some setup required
Laravel Event Projector
Laravel Event ProjectorIt's not full event sourcing, it focuses on projectionsBeautifully integrated into LaravelEasy to get started with
https://docs.spatie.be/laravel-event-projector
Demo
In closing
SummaryEasy to use package to get started with projectionsHooks into Laravel's native eventsReplay capabilitiesWrites are harder, reads are easier
Resourceshttps://kickstarter.engineering/event-sourcing-made-simple-4a2625113224https://dev.to/barryosull/event-sourcing-what-it-is-and-why-its-awesomehttps://www.youtube.com/watch?v=28jmTeN3VYchttps://github.com/eventsauce
Thank you!https://speakerdeck.com/freekmurze/projecting-events-in-laravelhttps://spatie.be/open-sourcehttps://murze.behttps://ohdear.apphttps://fullstackeurope.com