Laravel Controller Subfolder routing
For Laravel 5.3 above:
php artisan make:controller test/TestController
This will create the test
folder if it does not exist, then creates TestController
inside.
TestController
will look like this:
<?php
namespace App\Http\Controllers\test;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class TestController extends Controller
{
public function getTest()
{
return "Yes";
}
}
You can then register your route this way:
Route::get('/test','test\TestController@getTest');
Add your controllers in your folders:
controllers\
---- folder1
---- folder2
Create your route not specifying the folder:
Route::get('/product/dashboard', 'MakeDashboardController@showDashboard');
Run
composer dump-autoload
And try again