This helps you to organize your Laravel Project codes by modularizing all your controllers, views and models. This will be very helpful when your laravel project is very big and have a lots of modules.
-
Add following line after "App\": "app/" in composer.json "Modules\": "app/modules"
Example: "psr-4": { "App\": "app/", "Modules\": "app/modules" }
-
Copy module.php from source and paste it into your projects config directory.
-
Add required module name inside array: Example: return [ 'modules'=>array( "Admin", "Home", "Your_Module_Name" ), ];
-
Copy Modules directory from source to your projects App directory.
-
Modify Modules as per your requirement.
-
Now open up the file config/app.php and add ‘App\Modules\ModulesServiceProvider’ to the end of the providers array.
-
Your laravel project is now ready to go.
-
If you caught into problem: class not found then please do 'composer dump-autoload -o'.
Thank you so much Kamran Ahmed for this very nice tutorial.