$30 off During Our Annual Pro Sale. View Details »

Projecting events in Laravel (Laravel Live)

Projecting events in Laravel (Laravel Live)

Freek Van der Herten

March 03, 2019
Tweet

More Decks by Freek Van der Herten

Other Decks in Programming

Transcript

  1. Projecting events
    in Laravel

    View Slide

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

    View Slide

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

    View Slide

  4. Open Source 

    Software

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  9. Let's talk about
    projecting events

    View Slide

  10. Talk overview
    Theory
    Laravel Event Projector demo

    View Slide

  11. Theory

    View Slide

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

    View Slide

  13. APPLICATION
    DATABASE
    TABLE
    value X

    View Slide

  14. APPLICATION
    DATABASE
    TABLE
    value X
    value Y

    View Slide

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

    View Slide

  16. APP EVENTS
    Event
    Event 1

    View Slide

  17. APP EVENTS
    Event
    Event 1
    Event 2

    View Slide

  18. APP EVENTS
    Event
    Event 1
    Event 2
    Event 3

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  24. Laravel 

    Event Projector

    View Slide

  25. Laravel Event Projector
    It's not full event sourcing, it focuses on projections
    Beautifully integrated into Laravel
    Easy to get started with

    View Slide

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

    View Slide

  27. Demo

    View Slide

  28. In closing

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide