In this episode, we tackle a super practical question: what do you do when your Laravel app starts growing, and the default folder structure just isn't cutting it anymore? We walk through restructuring a fresh Laravel project so it's way easier to manage as your codebase grows.
You'll see how to set up new app
, domain
, and http
directories, drawing inspiration from Domain-Driven Design, without getting into the nitty gritty of DDD. We go step by step, moving files around, updating namespaces, and fixing the inevitable errors that pop up after moving stuff! You'll also see how to make sure all your authentication and registration logic keeps working, even after moving the User model and controllers around.
Once that's stable, we talk through organizing things by domain: putting models, events, listeners, and services specific to a part of your app (like Users, Auth, or Courses) inside their own folders. We also look at keeping HTTP-specific stuff (controllers, requests, transformers) inside the HTTP directory, and figure out what should be global (like certain exceptions or abstract classes in app
).
We wrap up by applying the structure to a real-world example and talk about the impact: clearer organization, easier navigation, and a codebase that doesn't get out of control as your app grows. The episode is packed with actionable tips, so you can start organizing your projects this way right away (or tweak it to fit your style).