Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Event sourcing in Laravel (full stack brussels)
Freek Van der Herten
April 04, 2019
Programming
1
230
Event sourcing in Laravel (full stack brussels)
Freek Van der Herten
April 04, 2019
Tweet
Share
More Decks by Freek Van der Herten
See All by Freek Van der Herten
An Introduction to Snapshot testing
freekmurze
0
210
Event Sourcing In Laravel
freekmurze
0
140
Building a realtime dashboard with Laravel Livewire (PHPKonf)
freekmurze
0
450
A tour behind the scenes of Oh Dear (PHP Benelux)
freekmurze
1
490
A practical look at multitenancy in Laravel
freekmurze
1
240
A practical look at multitenancy in Laravel (Laracon US)
freekmurze
0
450
Highlights Flare codebase (Laracon online)
freekmurze
0
180
Introducing Mailcoach
freekmurze
1
380
Highlights from the Flare codebase (Full Stack Ghent)
freekmurze
0
420
Other Decks in Programming
See All in Programming
Managing Error Messages with your Oracle Database REST APIs
thatjeffsmith
0
130
Baseline Profilesでアプリのパフォーマンスを向上させる / Improve app performance with Baseline Profiles
numeroanddev
0
250
Cybozu GoogleI/O 2022 LT会 - Input for all screens
jaewgwon
0
320
Meet Swift Regex
usamik26
0
350
Oracle REST Data Service: APEX Office Hours
thatjeffsmith
0
760
Power Automateドリブンのチームマネジメント
hanaseleb
0
190
Deep Dive Into Google Zanzibar and its Concepts for Authorization Scenarios
dschenkelman
1
130
NEWT.net: Frontend Technology Selection
xpromx
0
250
IE Graduation Certificate
jxck
6
4.8k
設計の学び方:自分流のススメ
masuda220
PRO
7
5.4k
[월간 데이터리안 세미나 6월] 스스로 성장하는 분석가 커리어 이야기
datarian
0
210
短納期でローンチした新サービスをJavaで開発した話/launched new service using Java
eichisanden
6
1.9k
Featured
See All Featured
Large-scale JavaScript Application Architecture
addyosmani
499
110k
The Art of Programming - Codeland 2020
erikaheidi
32
11k
How STYLIGHT went responsive
nonsquared
85
3.9k
Making Projects Easy
brettharned
98
4.3k
Streamline your AJAX requests with AmplifyJS and jQuery
dougneiner
127
8.5k
Happy Clients
brianwarren
89
5.6k
Designing Experiences People Love
moore
130
22k
Bash Introduction
62gerente
597
210k
4 Signs Your Business is Dying
shpigford
169
20k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_i
23
15k
BBQ
matthewcrist
74
7.9k
Facilitating Awesome Meetings
lara
29
4k
Transcript
Getting started with event sourcing in Laravel
About me Freek Van der Herten Partner & developer at
Spatie @freekmurze https://murze.be https://ohdear.app
Spatie Since 2003 Websites, applications and webshops Team 9 awesome
human beings Specialisation Laravel, front-end development
Open Source Software
We create a lot of it ± 200 packages on
Packagist ± 2,000,000 downloads a month ± 30,000,000 total downloads All Postcardware!
Highlights Popular laravel-backup laravel-medialibrary laravel-permission New laravel-query-builder laravel-blade-x
https://spatie.be/open-source
https://spatie.be/open-source/postcards
Let's talk about event sourcing
Talk overview Theory Laravel Event Projector demo Eventsauce demo
Theory
Traditional application Write data in database An update means overwriting
the old data The old data cannot be accessed anymore
APPLICATION DATABASE TABLE value X
APPLICATION DATABASE TABLE value X value Y
Event Sourced Application The application will fire off events Events
will get written in a dedicated store Events are passed to consumers that create projections Aggregate, Aggregate Root...
APP EVENTS Event Event 1
APP EVENTS Event Event 1 Event 2
APP EVENTS Event Event 1 Event 2 Event 3
APP CONSUMER EVENTS PROJECTION Event Event 1 Event 2 Event
3
APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event
2 Event 3 ANOTHER PROJECTION
APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event
2 Event 3 ANOTHER PROJECTION
APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event
2 Event 3 Event 4 ANOTHER PROJECTION
Event Sourced Application Auditing requirements Extra reports needed Recording the
unhappy path There is some setup required
Laravel Event Projector
Laravel Event Projector Package made by Spatie It's not full
event sourcing, it focuses on projections Beautifully integrated into Laravel Easy to get started with
https://docs.spatie.be/laravel-event-projector
Demo
Eventsauce
Eventsauce Package made by Frank De Jonge Focuses on aggregates
Framework agnostic Separate Laravel bindings package available Very powerful, adds complexity
https://eventsauce.io/docs/
APP Subtract $1000
AGGREGATE ROOT REPOSITORY UUID PAYLOAD TIME APP Subtract $1000
AGGREGATE ROOT REPOSITORY UUID PAYLOAD TIME APP Subtract $1000 RETRIEVE
Subtract $1000 AGGREGATE ROOT (empty)
AGGREGATE ROOT REPOSITORY ABC-123 Subtract 1000 11:12 AM UUID PAYLOAD
TIME APP Subtract $1000 RETRIEVE Subtract $1000 AGGREGATE ROOT ACCOUNTS CONSUMER -$1000 (empty) PERSIST
AGGREGATE ROOT REPOSITORY ABC-123 Subtract 1000 11:12 AM UUID PAYLOAD
TIME APP RETRIEVE Subtract $750 AGGREGATE ROOT ACCOUNTS -$1000 CONSUMER Subtract $750 Subtract $1000 PERSIST
AGGREGATE ROOT REPOSITORY ABC-123 Subtract 1000 11:12 AM ABC-124 Subtract
750 01:17 PM UUID PAYLOAD TIME APP RETRIEVE Subtract $750 AGGREGATE ROOT ACCOUNTS -$1750 CONSUMER Subtract $750 Subtract $1000 PERSIST
AGGREGATE ROOT REPOSITORY ABC-123 Subtract 1000 11:12 AM ABC-124 Subtract
750 01:17 PM UUID PAYLOAD TIME APP RETRIEVE AGGREGATE ROOT ACCOUNTS -$1750 CONSUMER Subtract $1250 Subtract $1000 Subtract $750 Subtract $1250 More Money Needed PERSIST
AGGREGATE ROOT REPOSITORY ABC-123 Subtract 1000 11:12 AM ABC-124 Subtract
750 01:17 PM ABC-125 Subtract 1250 05:51 PM ABC-126 More Money Needed 05:51 PM UUID PAYLOAD TIME ACCOUNTS APP CONSUMER CONSUMER 2 PROPOSED LOANS Subtract $1250 -$3000 RETRIEVE PERSIST Subtract $1000 Subtract $750 Subtract $1250 More Money Needed AGGREGATE ROOT
Demo
In closing
Summary Laravel Event Projector Easy to use package to get
started with projections Hooks into Laravel's native events Replay capabilities No aggregates
Summary EventSauce Framework agnostic Support for aggregates, process modelling No
replay capabilities out of the box https://github.com/spatie/laravel-eventsauce
Writes are harder, reads are easier
Event sourcing makes the easy things harder… …and the harder
things easier — Frank De Jonge
Larabank https://github.com/spatie/larabank-traditional https://github.com/spatie/larabank-event-projector https://github.com/spatie/larabank-eventsauce
Resources https://kickstarter.engineering/event-sourcing-made-simple-4a2625113224 https://github.com/spatie/laravel-event-projector https://github.com/eventsaucephp/eventsauce https://github.com/prooph
Thank you! https://speakerdeck.com/freekmurze/event-sourcing-full-stack-brussels https://spatie.be/open-source https://murze.be https://ohdear.app