Slide 1

Slide 1 text

Projecting events in Laravel

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Spatie Since 2003 Websites, applications and webshops Team 9 awesome human beings Specialisation Laravel, front-end development

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 ± 25,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 projecting events

Slide 10

Slide 10 text

Talk overview Theory Laravel Event Projector 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

Using projectors The application will fire off events Events will get written in a dedicated store Events are passed to classes that can handle them

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

Projecting events Auditing requirements Extra reports needed There is some setup required

Slide 24

Slide 24 text

Laravel 
 Event Projector

Slide 25

Slide 25 text

Laravel Event Projector It's not full event sourcing, it focuses on projections 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

In closing

Slide 29

Slide 29 text

Summary Easy to use package to get started with projections Hooks into Laravel's native events Replay capabilities Writes are harder, reads are easier

Slide 30

Slide 30 text

Resources https://kickstarter.engineering/event-sourcing-made-simple-4a2625113224 https://dev.to/barryosull/event-sourcing-what-it-is-and-why-its-awesome https://www.youtube.com/watch?v=28jmTeN3VYc https://github.com/eventsauce

Slide 31

Slide 31 text

Thank you! https://speakerdeck.com/freekmurze/projecting-events-in-laravel https://spatie.be/open-source https://murze.be https://ohdear.app https://fullstackeurope.com