Slide 1

Slide 1 text

Getting started with event sourcing in Laravel

Slide 2

Slide 2 text

About me Freek Van der Herten Partner & developer at Spatie @freekmurze murze.be ohdear.app

Slide 3

Slide 3 text

Spatie Laravel, front-end development Since 2003 9 awesome human beings

Slide 4

Slide 4 text

Open Source 
 Software

Slide 5

Slide 5 text

We create a lot of it ± 200 packages on Packagist ± 2,000,000 downloads a month ± 30,000,000 total downloads All Postcardware!

Slide 6

Slide 6 text

Highlights Popular laravel-backup laravel-medialibrary laravel-permission New laravel-query-builder laravel-blade-x

Slide 7

Slide 7 text

https://spatie.be/open-source

Slide 8

Slide 8 text

https://spatie.be/open-source/postcards

Slide 9

Slide 9 text

Let's talk about event sourcing

Slide 10

Slide 10 text

Talk overview Theory Projectors demo Aggregates demo

Slide 11

Slide 11 text

Theory

Slide 12

Slide 12 text

Traditional application Write data in database An update means overwriting the old data The old data cannot be accessed anymore

Slide 13

Slide 13 text

APPLICATION DATABASE TABLE value X

Slide 14

Slide 14 text

APPLICATION DATABASE TABLE value X value Y

Slide 15

Slide 15 text

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...

Slide 16

Slide 16 text

APP EVENTS Event Event 1

Slide 17

Slide 17 text

APP EVENTS Event Event 1 Event 2

Slide 18

Slide 18 text

APP EVENTS Event Event 1 Event 2 Event 3

Slide 19

Slide 19 text

APP CONSUMER EVENTS PROJECTION Event Event 1 Event 2 Event 3

Slide 20

Slide 20 text

APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event 2 Event 3 ANOTHER PROJECTION

Slide 21

Slide 21 text

APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event 2 Event 3 ANOTHER PROJECTION

Slide 22

Slide 22 text

APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event 2 Event 3 Event 4 ANOTHER PROJECTION

Slide 23

Slide 23 text

Event Sourced Application Auditing requirements Extra reports needed Recording the unhappy path There is some setup required

Slide 24

Slide 24 text

Laravel 
 Event Projector

Slide 25

Slide 25 text

Laravel Event Projector Package made by Spatie Aggregates, Projectors & Reactors Beautifully integrated into Laravel Easy to get started with

Slide 26

Slide 26 text

https://docs.spatie.be/laravel-event-projector

Slide 27

Slide 27 text

Demo

Slide 28

Slide 28 text

Aggregates

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

No content

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

No content

Slide 35

Slide 35 text

Demo

Slide 36

Slide 36 text

In closing

Slide 37

Slide 37 text

Summary Laravel Event Projector Easy to use package to get started with event sourcing Projectors Replay capabilities Aggregates

Slide 38

Slide 38 text

Writes are harder, reads are easier

Slide 39

Slide 39 text

Event sourcing makes the easy things harder… …and the harder things easier — Frank De Jonge

Slide 40

Slide 40 text

Larabank github.com/spatie/larabank-traditional github.com/spatie/larabank-event-projector github.com/spatie/larabank-event-projector-aggregates github.com/spatie/larabank-eventsauce

Slide 41

Slide 41 text

Resources kickstarter.engineering/event-sourcing-made-simple-4a2625113224 github.com/spatie/laravel-event-projector github.com/eventsaucephp/eventsauce github.com/prooph

Slide 42

Slide 42 text

Thank you! speakerdeck.com/freekmurze/event-sourcing-full-stack-ghent spatie.be/open-source murze.be ohdear.app