Laravel error 'ReflectionException' - 'Class App\Http\Kernel does not exist'

NicoSalvadore picture NicoSalvadore · Aug 12, 2016 · Viewed 24.9k times · Source

I was trying to go live with a laravel project i developped a year back in school and i ran into some issue. After uploading the whole project on my hosting service's server, i got these errors on my browser as well as on my SSH shell.

Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist' in /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php:779 Stack trace: #0 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('App\Http\Kernel') #1 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(659): Illuminate\Container\Container->build('App\Http\Kernel', Array) #2 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(644): Illuminate\Container\Container->make('App\Http\Kernel', Array) #3 /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(229): Illuminate\Foundation\Application->make('App\Http\Kernel', Array) #4 /home/clients/ffa41f94063 in /home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779

I think it could be related to my namespace configuration, because i haven't all understood yet.

Here is my composer.json file :

What I have already done :

  • Delete /vendor and make a new install with composer install
  • composer dump-autoload
  • composer update btw, I get the error when I insert the composer update

Please inform me if i should post another file that could be useful.

Thanks in advance for your help.

Answer

Roger Creasy picture Roger Creasy · Aug 12, 2016

In composer.json change:

 "psr-4": {
        "App\\": "myforms/app/"
    } 

to:

 "psr-4": {
        "App\\": "app/"
    }

On the server, in your source directory, run composer update then composer dump-autoload

PSR-4 in Laravel looks for namespaces relative to the root of the project