Skip to content
Advertisement

laravel is giving error on custom controller used in routes

I have a simple in routes/web.php file

Route::get(Config::get('constants.ADMIN_PATH') . '/categories', 'AdminControllersAdminPagesController@index');

I have made a folder AdminControllers and inside that there is a controller named AdminPagesController but i am getting error as

Class AppHttpControllersAdminControllersAdminPagesController does not exist

Whereas i looked into the same folder and class exist. Here is my class code

namespace AppHttpControllers;

use IlluminateHttpRequest;

class AdminPagesController extends Controller
{
    public function __construct() {

    }

    public function index () {
        return "hello";
    }
}

Advertisement

Answer

Change you namespace to

namespace AppHttpControllersAdminControllers;

Laravel will resolve controllers based on your name spacing, not on your directory structure.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement