I'm working on a PHP project with Laravel 5 and I'm thinking of setting up a different folder structure for it.
The standard Laravel folder structure is something like this:
/app
/commands
/Http
/Controllers
/Middleware
Kernel.php
routes.php
/Providers
Model.php
/config
/resources
etc...
However, when the project grows larger and you have a lot of Controllers/Repositories/Models and such. This structure is gonna break.
For example: it's not very easy to find a bug in your admin panel if you have to dig through your routes, find which controller is responsible, find that controller amongst a large set of controllers, find out what that does, find out other possibly responsible classes in other large folders, and so on. In short: it's a mess.
I've been looking at ways to break the structure into modules. I've come up with a way to do it, but I'm not sure if it's a good way.
I would make a folder each functionality and put all the related code together. For example:
/app
/Admin
/Controllers
/Requests
/Models
routes.php
/Products
/Controllers
/Requests
/Models
routes.php
etc. (you get the point)
Instead of initializing 1 router from the standard RouteServiceProvider.php, I would have to write a ServiceProvider for each module and start all individual routes from there. So in this case I would have an AdminServiceProvider and a ProductServiceProvider which each require the routes.php file in their own subdirectory (and with that their own controller namespace).
This seems to solve my case for now, but I'm wondering if I'm gonna run into trouble with this setup. All the examples I can find on the web just stick to the standard structure. Can anyone tell me if this is a decent way to do it? Or does anyone have an alternate way of doing this?