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

Highlights Flare codebase (Laracon online)

Highlights Flare codebase (Laracon online)

Freek Van der Herten

February 26, 2020
Tweet

More Decks by Freek Van der Herten

Other Decks in Programming

Transcript

  1. View Slide

  2. About me
    Freek Van der Herten
    Partner & developer at Spatie
    @freekmurze
    freek.dev
    spatie.be
    mailcoach.app
    ohdear.app
    flareapp.io

    View Slide

  3. Open source stats
    ± 250 packages on Packagist
    ± 60,000,000 total downloads
    ± 4 000,000 downloads a month
    spatie.be/open-source/packages

    View Slide

  4. Our address
    SPATIE
    Kruikstraat 22, Box 12
    BE-2018 Antwerp
    Belgium
    Europe

    View Slide

  5. spatie.be/open-source/postcards

    View Slide

  6. Our address
    SPATIE
    Kruikstraat 22, Box 12
    BE-2018 Antwerp
    Belgium
    Europe

    View Slide

  7. spatie.cards (by Chris Morell)

    View Slide

  8. Highlights from
    the Flare codebase

    View Slide

  9. A way to structure
    a large Laravel app

    View Slide

  10. About this talk
    Take a look at the Flare codebase
    Not a sales talk
    Techniques you can use in your own projects
    Opinionated

    View Slide

  11. Topics we'll cover
    Short walkthrough of the UI
    Naming things
    Domains
    Inertia / React / TypeScript

    View Slide

  12. Let's take a look
    at Flare

    View Slide

  13. Naming things

    View Slide

  14. PublishScheduledPosts
    A command?
    A job?

    View Slide

  15. PublishScheduledPostsCommand

    View Slide

  16. AccountActivated
    An event?
    A mail?
    A notification?

    View Slide

  17. AccountActivatedMail

    View Slide

  18. User
    A model?
    A resource?

    View Slide

  19. UserResource

    View Slide

  20. Naming things
    Use suffixes
    Immediately recognisable
    Makes it easier to find stuff in your project
    Less aliasing needed

    View Slide

  21. https://guidelines.spatie.be/code-style/laravel-php#naming-classes

    View Slide

  22. Using domains

    View Slide

  23. Using domains
    Term taken from DDD
    A sphere of knowledge
    Grouping code
    Larger projects

    View Slide

  24. Refactor to domains
    app/
    ├── Models/
    │ ├── User.php
    │ ├── Team.php
    │ └── Project.php
    ├── Mails/
    │ ├── Welcome.php
    │ ├── InvitedToTeam.php
    │ └── ApiKeyRegenerated.php
    └── Events/
    ├── UserDeleted.php
    └── Project.php

    View Slide

  25. Refactor to domains
    app/
    └── Domain/
    ├── Team
    └── Project

    View Slide

  26. Show me the code

    View Slide

  27. Front end

    View Slide

  28. Front end
    “I strongly believe JavaScript is a requirement for excellent user
    experiences. Not good experiences, excellent experiences.”
    —Seb

    View Slide

  29. Front end: JavaScript
    Inertia
    Built by Jonathan Reinink
    Replace Blade by React (or Vue or whatever)
    Makes server client communication seamless
    No full pages refreshes

    View Slide

  30. public function index(Team $team)
    {
    return view('team.settings', compact('team'));
    }

    View Slide

  31. public function index(Team $team)
    {
    return inertia()->render('team.settings', compact('team'));
    }

    View Slide

  32. Show me!

    View Slide

  33. In closing

    View Slide

  34. https://guidelines.spatie.be/code-style/laravel-php#naming-classes

    View Slide

  35. Using domains
    stitcher.io/blog/laravel-beyond-crud-01-domain-oriented-laravel
    freek.dev/1371-refactoring-to-actions
    freek.dev/1433-supercharging-common-controllers

    View Slide

  36. Shameless plugs
    https://mailcoach.app
    Self-hosted newsletter engine + video course
    MAILCOACH-LOVES-LARACON-ONLINE: $20 discount
    https://ohdear.app
    Uptime tracker, status pages, broken links checks on all pages
    OHDEAR-LOVES-LARACON-ONLINE: first month for free
    https://flareapp.io
    Exception tracker for Laravel apps
    FLARE-LOVES-LARACON-ONLINE: $29 discount on your first bill

    View Slide

  37. One more thing

    View Slide

  38. medialibrary.pro

    View Slide

  39. Thank you!
    speakerdeck.com/freekmurze/highlights-flare-codebase-laracon-online
    spatie.be/open-source
    freek.dev
    mailcoach.app
    ohdear.app
    flareapp.io

    View Slide