Reputation: 9037
I'm trying to use a controller inside a folder in the controllers directory like
route
Route::get('/','site\HomeController@index');
but seem's does not work like it gives me this error
Class App\Http\Controllers\site\HomeController does not exist
Note: I have also a HomeController.php in the controllers folder. I'm trying to organize my controllers by putting them unto their specific folders.
Any help, ideas please?
Upvotes: 1
Views: 349
Reputation: 17658
The namespace of the class HomeController
should be as:
namespace App\Http\Controllers\Site;
And in your route file you can use it as:
Route::get('/','Site\HomeController@index');
Remember to add following line of code in HomeController
class as:
use App\Http\Controllers\Controller;
Upvotes: 1
Reputation: 163748
You should use proper namespace, like:
namespace App\Http\Controllers\Site;
And add this line:
use App\Http\Controllers\Controller;
Then this route will work:
Route::get('/','Site\HomeController@index');
Upvotes: 2