Laravel 4.2 to 5 Class 'App\Http\Controllers\Controller' not found

Paulo Coghi picture Paulo Coghi · Mar 23, 2015 · Viewed 6.9k times · Source

I upgraded my project from Laravel 4.2 to 5.0 but I get this error when I finish the process:

Class 'App\Http\Controllers\Controller' not found' in .../app/Http/Controllers/Auth/AuthController.php:8

But the mentioned controller is there, in app/Http/Controllers/Controller.php.

Also it is defined in composer.json, autoload, classmap:

"autoload": {
        "classmap": [
            "database",
            "app/Http/Controllers",
            "app/Libraries"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },

Apparently this is a namespace problem, but I don't know hot to solve it

Answer

Paulo Coghi picture Paulo Coghi · May 13, 2015

In 99% of the cases the main cause of classes being not found when you migrate a Laravel 4 project to Laravel 5 is the lack of Namespaces

It is important to add namespaces to all your classes, controllers, old filters as middleware, etc.