Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

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

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

spatie.be/open-source/postcards

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

spatie.cards (by Chris Morell)

Slide 8

Slide 8 text

Highlights from the Flare codebase

Slide 9

Slide 9 text

A way to structure a large Laravel app

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

Let's take a look at Flare

Slide 13

Slide 13 text

Naming things

Slide 14

Slide 14 text

PublishScheduledPosts A command? A job?

Slide 15

Slide 15 text

PublishScheduledPostsCommand

Slide 16

Slide 16 text

AccountActivated An event? A mail? A notification?

Slide 17

Slide 17 text

AccountActivatedMail

Slide 18

Slide 18 text

User A model? A resource?

Slide 19

Slide 19 text

UserResource

Slide 20

Slide 20 text

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

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

Using domains

Slide 23

Slide 23 text

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

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

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

Slide 26

Slide 26 text

Show me the code

Slide 27

Slide 27 text

Front end

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

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

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

Show me!

Slide 33

Slide 33 text

In closing

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

One more thing

Slide 38

Slide 38 text

medialibrary.pro

Slide 39

Slide 39 text

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