There is a base namespace in RouteServiceProvider :
protected $namespace = 'App\Http\Controllers';
So if you want to have custom namespace you should change it or delete it :
protected $namespace = '';
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using laravel 5. My AdminController looks like that:
<?php namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
class AdminController extends Controller {
...
public function index()
{
return view('admin.index');
}
}
My routes look like that:
<?php
...
Route::group(array('prefix' => 'admin'), function()
{
Route::get('/', 'Admin\AdminController@index');
});
My file path looks like that:
app/Http/Controllers/Admin/AdminController.php
However, I get the following exception when I open the public folder of my application:
ReflectionException in Container.php line 776:
Class App\Http\Controllers\Admin\AdminController does not exist
Any suggestions why the controller cannot be found?
The problem is in here, Your class in is 'App\Http\Controllers\Admin\AdminController'
But you set your namespace to 'App\Http\Controllers\Auth'
change it to '''App\Http\Controllers\Admin"
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
class AdminController extends Controller {
public function index()
{
return view('admin.index');
}
}
Please or to participate in this conversation.