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

I shall define this only once

I shall define this only once

Freek Van der Herten

September 14, 2022
Tweet

More Decks by Freek Van der Herten

Other Decks in Programming

Transcript

  1. I shall say define this only once

    View Slide

  2. About me


    Freek Van der Herten


    Developer at SPATIE


    @freekmurze


    freek.dev


    mailcoach.app


    ohdear.app


    fl
    areapp.io

    View Slide

  3. Open source


    ± 300 packages on Packagist


    ± 360 000 000 downloads total


    ± 20 000 000 downloads a month

    View Slide

  4. spatie.be/open-source

    View Slide

  5. spatie.be/open-source/postcards

    View Slide

  6. Let’s talk about
    Laravel Data

    View Slide

  7. At Spatie


    Big projects


    Complex data, lots of properties and relations


    A lot data structures de
    fi
    ned multiple times for di
    ff
    erent
    purposes


    Form requests, API resources, TypeScript de
    fi
    nitions

    View Slide

  8. Laravel Data


    An easy to use Laravel package


    Create powerful data objects


    A single de
    fi
    nition that can be used for multiple purposes


    Created by Ruben Van Assche


    250K downloads

    View Slide

  9. This talk


    A simple example


    Real world usage in Flare

    View Slide

  10. Let’s code

    View Slide

  11. In closing

    View Slide

  12. Laravel Data


    Rich data objects


    De
    fi
    ne a data structure only once


    Can replace API resources, Form Requests, …


    Generating TypeScript de
    fi
    nitions


    View Slide

  13. Laravel Data


    Optional properties


    Lazy loading of properties


    Create data from incoming requests, JSON and objects


    In
    fi
    nitely con
    fi
    gurable


    … and a whole lot more

    View Slide

  14. spatie.be/docs/laravel-data

    View Slide

  15. Laravel Data


    For everything


    For only small parts


    Don’t just discard the Laravel defaults


    Do what is best for your team and project


    View Slide

  16. One more thing

    View Slide

  17. Laracon Promo


    20% discount on all spatie products, no coupon needed


    spatie.be/products


    Products: Ray, Mailcoach, Laravel Comments, MediaLibrary Pro


    Courses: Testing Laravel, Laravel Package Training, Laravel
    Beyond Crud, Writing Readable Laravel, Laravel Event
    Sourcing


    View Slide

  18. Thank you!


    freek.dev


    mailcoach.app


    spatie.be


    ohdear.app


    fl
    areapp.io

    View Slide