In general, I think it's good advice, but I guess it comes down to what you consider “close”.

For our bigger apps that have lots of logic and models we like to work with a domain oriented approach.

🧵 A few examples and thoughts on this.


#laravel #php
A domain is basically a way of grouping the logic of some parts so that you can work on that small parts without having to deal with all classes in your app.

It's sound heavy but it's actually a pretty lightweight practice. We talk about it in our book: laravel-beyond-crud.com
The "stick close to the default structure" mantra is the result of people who tried to go too far by putting stuff outside of the app directory, requiring service providers, splitting up resources/config directories.

When refactoring to domains, you're only changing a namespace.
Laravel doesn't care where classes are located.

You can refactor to a domain oriented approach if needed, simply by moving namespace around (you can do that very quickly with an IDE like PhpStorm).

You can see me do it here for @getmailcoach
Here's another example taken from the flareapp.io codebase.

By splitting our app up in domains, we can just focus on projects, our team functionality when we need to make changes.
Another example, for another big Laravel app: @OhDearApp

Oh Dear performs several types of checks, the all require a lot of logic. Those checks all live in the Checks domain under their own namespace.

This makes it easy for me to work on a single type of check.
When starting out with a new app, we usually don't create domains, we only do that when we feel it's needed.

Refactoring to domains only takes a couple of minutes, and it's easy to change domains, or revert back.

Make up your own mind if you find this practice useful.
Bonus thought: If you decide to refactor to domains, don’t go overboard with it: not only every little feature deserves its own domain. For a maintainer, it should be easy to guess which logic is in which domain.

For more info: laravel-beyond-crud.com

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with Freek Van der Herten 🔭

Freek Van der Herten 🔭 Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @freekmurze

Jan 18
🚀 I'm proud to share that our team has released a new major version of Ignition. It's the most beautiful error page you ever seen, and it will be the default in @laravelphp 9

👍You can also install it in Laravel 8!

🧵 Let's take a look at all the features
At the top there's a new Docs item which will go straight to the Laravel documentation. That red dot means we found a very specific page (for instance the Eloquent page for query errors)

Settings can now be saved right in Ignition itself, you don't have to edit a config file.
🌚 YES! We do have a dark mode! 😍
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(