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

Highlights Flare codebase (Laracon online)

Highlights Flare codebase (Laracon online)

A1b4b398630bbd32b77a82cbc37fae9a?s=128

Freek Van der Herten

February 26, 2020
Tweet

More Decks by Freek Van der Herten

Other Decks in Programming

Transcript

  1. None
  2. About me Freek Van der Herten Partner & developer at

    Spatie @freekmurze freek.dev spatie.be mailcoach.app ohdear.app flareapp.io
  3. Open source stats ± 250 packages on Packagist ± 60,000,000

    total downloads ± 4 000,000 downloads a month spatie.be/open-source/packages
  4. Our address SPATIE Kruikstraat 22, Box 12 BE-2018 Antwerp Belgium

    Europe
  5. spatie.be/open-source/postcards

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

    Europe
  7. spatie.cards (by Chris Morell)

  8. Highlights from the Flare codebase

  9. A way to structure a large Laravel app

  10. About this talk Take a look at the Flare codebase

    Not a sales talk Techniques you can use in your own projects Opinionated
  11. Topics we'll cover Short walkthrough of the UI Naming things

    Domains Inertia / React / TypeScript
  12. Let's take a look at Flare

  13. Naming things

  14. PublishScheduledPosts A command? A job?

  15. PublishScheduledPostsCommand

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

  17. AccountActivatedMail

  18. User A model? A resource?

  19. UserResource

  20. Naming things Use suffixes Immediately recognisable Makes it easier to

    find stuff in your project Less aliasing needed
  21. https://guidelines.spatie.be/code-style/laravel-php#naming-classes

  22. Using domains

  23. Using domains Term taken from DDD A sphere of knowledge

    Grouping code Larger projects
  24. Refactor to domains app/ ├── Models/ │ ├── User.php │

    ├── Team.php │ └── Project.php ├── Mails/ │ ├── Welcome.php │ ├── InvitedToTeam.php │ └── ApiKeyRegenerated.php └── Events/ ├── UserDeleted.php └── Project.php
  25. Refactor to domains app/ └── Domain/ ├── Team └── Project

  26. Show me the code

  27. Front end

  28. Front end “I strongly believe JavaScript is a requirement for

    excellent user experiences. Not good experiences, excellent experiences.” —Seb
  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
  30. public function index(Team $team) { return view('team.settings', compact('team')); }

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

  32. Show me!

  33. In closing

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

  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

  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
  37. One more thing

  38. medialibrary.pro

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