Laravel: Controller does not exist

In my case, in the top of my controller code i add this line :

namespace App\Http\Controllers\CustomFolder\ControllerClassName;

and my problem is solved


We can create controller via command line.

php artisan make:controller nameController --plain.

Before Laravel 5, make namespace is not available. Instead, this works

php artisan controller:make nameController

Execute your command inside your project directory and then create your function.


Did you add autoload classmap to composer.json file? Open your composer.json file and add

"autoload": {
        "classmap": [
            "app/controllers/admin",
        ]
    }

if you add folders inside controllers, you need to add it to composer.json file. Then run

composer dumpautoload

OR ALTERNATIVE

go to app/start/global.php and add

ClassLoader::addDirectories(array(
    app_path().'/controllers/admin',
));