jmagnuss
2 years ago

Laravel best practices for real-world app architecture

Posted 2 years ago by jmagnuss

I build or maintain on multiple Laravel projects for different companies, and as they grow I end up being unhappy with the size of the Controllers, so I'm reading up on Domain Driven Design, and the general preference for Fat Model, Thin Controller.

HOWEVER

  1. That preference seems simplistic and outdated (per @JeffreyWay on twitter). instead it's more like "Many small business classes, thin everything"?
  2. This StackOverflow answer gives a great breakdown of app organization, from model to repository to [...] to controller to view, but kind of skips the middle where you DO THINGS using your models before returning to the controllers.
  3. The recommended books Laravel: from Apprentice to Artisan and Implementing Laravel are 4+ years old now.

I'm steeped in old school GOF patterns and refactoring, so I know how to implement factories, repositories, and builders in classes I could throw in the app directory alongside my models, but this seems messy.

I'm craving:

  • authoritative best practices for L5 project architecture that go beyond "posts and comments" examples
  • recommendations on where to locate business logic between models and controllers in a Laravel-ey way

Point me at resources! Make suggestions! Let me know what key Laracast video or book I've missed!

Many thanks, LC community.

Please sign in or create an account to participate in this conversation.