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 Slide

  2. 25-03-2021 @matyo91
    Why ?

    View Slide

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

    View Slide

  4. @matyo91
    25-03-2021
    Programming
    Paradigm

    View Slide

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

    View Slide

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


    Top Layer : « communication logic »

    View Slide

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

    View Slide

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

    View 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 Slide

  10. @matyo91
    25-03-2021

    View Slide

  11. @matyo91
    25-03-2021

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View 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 Slide

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

    View Slide

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

    View Slide

  19. Implementation
    @matyo91
    PHP
    25-03-2021

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  23. Demo
    @matyo91
    25-03-2021
    PHP

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



    Elixir


    https://github.com/antonmi/flowex

    View Slide

  24. Hello!


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

    View Slide