Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PHP Railway Flow Based Programming

PHP Railway Flow Based Programming

This talk is about Railway Flow Based Programming based from the work of Anton Mishchuk

https://anton-mishchuk.medium.com/railway-flow-based-programming-with-flowex-ef04fd338e41

Here we present the concept and show an implementation in PHP

Source code associated to this talk

https://github.com/darkwood-fr/flow

Article associated to this talk

https://blog.darkwood.fr/article/php-railway-flow-based-programming

Video associated to this talk

https://www.youtube.com/watch?v=u7LTuBRlITA

Mathieu Ledru

March 25, 2021
Tweet

More Decks by Mathieu Ledru

Other Decks in Programming

Transcript

  1. Railway Flow Based Programming
    @matyo91
    25-03-2021
    In PHP

    View full-size slide

  2. 25-03-2021 @matyo91
    Why ?

    View full-size slide

  3. Flow Based Programming
    @matyo91
    Basic concepts
    25-03-2021

    View full-size slide

  4. @matyo91
    25-03-2021
    Programming
    Paradigm

    View full-size slide

  5. @matyo91
    25-03-2021
    Express a
    problem in terms
    of transforms on
    streams of data

    View full-size slide

  6. Two layers in FBP application
    @matyo91
    @matyo91
    25-03-2021
    Botton layer : « business logic »


    Top Layer : « communication logic »

    View full-size slide

  7. Advantages
    @matyo91
    @matyo91
    25-03-2021

    View full-size slide

  8. Railway Oriented Programming
    @matyo91
    Design pattern
    25-03-2021

    View full-size slide

  9. Request : (userId, name, email)


    Name is blank, email is not valid


    User DB not found


    Authorization error Timeout
    Exemple
    @matyo91
    Receive request
    Validate and canonicalize request
    Update existing user record
    Send verification email
    Return result to user
    25-03-2021

    View full-size slide

  10. @matyo91
    25-03-2021

    View full-size slide

  11. @matyo91
    25-03-2021

    View full-size slide

  12. Functional
    approach for
    managing errors
    @matyo91
    25-03-2021

    View full-size slide

  13. Railway Flow Based Programming
    @matyo91
    Introduction
    25-03-2021

    View full-size slide

  14. @matyo91
    AddOne MulByTwo MinusThree
    25-03-2021

    View full-size slide

  15. @matyo91
    addOne MulByTwo MinusThree
    Supervisor
    Producer Consumer
    Error
    25-03-2021

    View full-size slide

  16. @matyo91
    AddOne
    MulByTwo
    MinusThree
    Producer
    Consumer
    Client
    25-03-2021
    Supervisor
    IP {number:3}
    IP {number:3}
    IP {number:4}
    IP {number:5}
    IP {number:5}
    IP {number:8}

    View full-size slide

  17. @matyo91
    Producer
    Consumer
    Client
    Client
    Client Rails
    25-03-2021
    Supervisor
    IP
    IP
    IP
    IP
    IP
    IP
    IP
    IP

    View full-size slide

  18. @matyo91
    AddOne MulByTwo
    MinusThree
    Producer Consumer
    Error
    MulByTwo
    MulByTwo
    MinusThree Error
    25-03-2021

    View full-size slide

  19. Implementation
    @matyo91
    PHP
    25-03-2021

    View full-size slide

  20. Symfony Messenger
    @matyo91
    @matyo91
    25-03-2021

    View full-size slide

  21. Supervisor
    Symfony Messenger
    @matyo91
    @matyo91
    25-03-2021
    Client
    IP IP
    IP
    IP
    Rails & Error
    Consumer
    Producer

    View full-size slide

  22. Asynchron
    @matyo91
    @matyo91
    25-03-2021

    View full-size slide

  23. Demo
    @matyo91
    25-03-2021
    PHP

    https://github.com/darkwood-fr/railway-fbp



    Elixir


    https://github.com/antonmi/flowex

    View full-size slide

  24. Hello!


    I Am Mathieu Ledru
    You can contact me at @matyo91
    @matyo91
    Thanks!
    Any questions?
    25-03-2021

    View full-size slide