Event Sourcing in Laravel (Full Stack Ghent)

Event Sourcing in Laravel (Full Stack Ghent)

A1b4b398630bbd32b77a82cbc37fae9a?s=128

Freek Van der Herten

April 10, 2019
Tweet

Transcript

  1. Getting started with event sourcing in Laravel

  2. About me Freek Van der Herten Partner & developer at

    Spatie @freekmurze murze.be ohdear.app
  3. Spatie Laravel, front-end development Since 2003 9 awesome human beings

  4. Open Source 
 Software

  5. We create a lot of it ± 200 packages on

    Packagist ± 2,000,000 downloads a month ± 30,000,000 total downloads All Postcardware!
  6. Highlights Popular laravel-backup laravel-medialibrary laravel-permission New laravel-query-builder laravel-blade-x

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

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

  9. Let's talk about event sourcing

  10. Talk overview Theory Projectors demo Aggregates demo

  11. Theory

  12. Traditional application Write data in database An update means overwriting

    the old data The old data cannot be accessed anymore
  13. APPLICATION DATABASE TABLE value X

  14. APPLICATION DATABASE TABLE value X value Y

  15. 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...
  16. APP EVENTS Event Event 1

  17. APP EVENTS Event Event 1 Event 2

  18. APP EVENTS Event Event 1 Event 2 Event 3

  19. APP CONSUMER EVENTS PROJECTION Event Event 1 Event 2 Event

    3
  20. APP CONSUMER CONSUMER 2 EVENTS PROJECTION Event Event 1 Event

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

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

    2 Event 3 Event 4 ANOTHER PROJECTION
  23. Event Sourced Application Auditing requirements Extra reports needed Recording the

    unhappy path There is some setup required
  24. Laravel 
 Event Projector

  25. Laravel Event Projector Package made by Spatie Aggregates, Projectors &

    Reactors Beautifully integrated into Laravel Easy to get started with
  26. https://docs.spatie.be/laravel-event-projector

  27. Demo

  28. Aggregates

  29. None
  30. None
  31. None
  32. None
  33. None
  34. None
  35. Demo

  36. In closing

  37. Summary Laravel Event Projector Easy to use package to get

    started with event sourcing Projectors Replay capabilities Aggregates
  38. Writes are harder, reads are easier

  39. Event sourcing makes the easy things harder… …and the harder

    things easier — Frank De Jonge
  40. Larabank github.com/spatie/larabank-traditional github.com/spatie/larabank-event-projector github.com/spatie/larabank-event-projector-aggregates github.com/spatie/larabank-eventsauce

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

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