I'm new to Laravel. To try and keep my app organized I would like to put my controllers into subfolders of the controller folder.
controllers\ ---- folder1 ---- folder2 I tried to route to a controller, but laravel doesn't find it.
Route::get('/product/dashboard', 'folder1.MakeDashboardController@showDashboard'); What am I doing wrong?
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');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With