1

The file actually exists. Not sure how to fix the error. Trying to clear the cache because the code changes I made in the file is not displaying on my site. I couldn't submit it because StackOverflow was telling me this post had too much code.

PHP Fatal error:  Uncaught ReflectionException: Class App\Console\Kernel does not exist in /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php:752
     Stack trace:
#0 /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php(752): ReflectionClass->__construct('App\\Console\\Ker...')
#1 /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php(631): Illuminate\Container\Container->build('App\\Console\\Ker...')
#2 /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php(586): Illuminate\Container\Container->resolve('App\\Console\\Ker...', Array)
#3 /var/www/stage/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(732): Illuminate\Container\Container->make('App\\Console\\Ker...', Array)
#4 /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php(256): Illuminate\Foundation\Application->make('App\\Console\\Ker...', Array)
#5 /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php(749): in /var/www/stage/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 752

Inside my composer file. Saw someone with similar problem post theirs so I thought it might help.

    {
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=7.0.0",
        "laravel/framework": "5.5.*",
        "maatwebsite/excel": "~2.1.0",
        "laravelcollective/html": "~5.0",
        "phpoffice/phpspreadsheet": "^1.2",
        "symfony/dom-crawler": "^4.0",
        "watson/sitemap": "^2.0",
        "laravel/socialite": "^3.1"
    },
    "require-dev": {
        "filp/whoops": "~2.0",
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~6.0",
        "symfony/css-selector": "2.8.*|3.0.*"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ],
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "pre-update-cmd": [
            "php artisan clear-compiled"
        ],
        "post-update-cmd": [
            "php artisan optimize"
        ],
         "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover"
        ]
    },
    "config": {
        "preferred-install": "dist"
    }
     }

Somebody requested to see what the Kernel file looks like:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

 class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        // Commands\Inspire::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
    }
}```

user2984757
  • 29
  • 3
  • 8
  • 1
    Does this answer your question? [Laravel error 'ReflectionException' - 'Class App\Http\Kernel does not exist'](https://stackoverflow.com/questions/38918982/laravel-error-reflectionexception-class-app-http-kernel-does-not-exist) – Pushprajsinh Chudasama Dec 07 '19 at 05:27
  • Nope. Ran the commands that were suggested. Got the same error that I got when I tried clearing the cache. – user2984757 Dec 07 '19 at 05:44
  • and what command did you run? – lagbox Dec 07 '19 at 05:46
  • See the answer below by Bhavik. Ran both commands. – user2984757 Dec 07 '19 at 05:52
  • what 'artisan' command did you run that you think is clearing some cache, that gave you the original error? – lagbox Dec 07 '19 at 05:56
  • php artisan cache:clear – user2984757 Dec 07 '19 at 06:00
  • 1
    what are you updating that isn't showing the changes? because that command is for your cache store which is almost never the issue ... and the file `app/Console/Kernel.php` does exist and it has the namespace declared as `App\Console`? if you have modified this file at all, it is possible there is an error in it which is stopping it from being loaded, you would need to look through the trace to see if there is more than 1 error – lagbox Dec 07 '19 at 06:02
  • show us the content of `/app/Console/Kernel.php` – porloscerros Ψ Dec 07 '19 at 06:18
  • @lagbox where is the namespace declared at? I don't see `App\Console` anywhere. – user2984757 Dec 07 '19 at 17:25
  • I think if you didn't change anything, you should have the file just like the one that laravel brings by default [Kernel.php](https://github.com/laravel/laravel/blob/5.5/app/Console/Kernel.php). For example, I don't see the `commands()` method in your Kernel class. I don't know if it's related, but you could try that. – porloscerros Ψ Dec 07 '19 at 18:48
  • It may also be useful to compare the files [composer.json](https://github.com/laravel/laravel/blob/5.5/composer.json). I chose version 5.5, since it is the only one that matches the required php that shows your file. – porloscerros Ψ Dec 07 '19 at 18:49
  • @porloscerrosΨ What do you mean? What should I try doing? – user2984757 Dec 07 '19 at 19:35
  • Try leaving the content of the file `Kernel.php` as it is by default [Kernel.php](https://github.com/laravel/laravel/blob/5.5/app/Console/Kernel.php) – porloscerros Ψ Dec 07 '19 at 21:54
  • @porloscerrosΨ I've never touched that file. Didn't even know it existed. A buddy of mine suggested I delete the vendor folder and the composer.lock file, then reinstall composer. But when I delete the folder and the file, I get a new error when I try to install composer. – user2984757 Dec 07 '19 at 23:33
  • The error: Could not scan for classes inside "tests/TestCase.php" which does not appear to be a file nor a folder. PHP Warning: require(/var/www/stage/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/stage/bootstrap/autoload.php on line 17 PHP Fatal error: require(): Failed opening required '/var/www/stage/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php') in /var/www/stage/bootstrap/autoload.php on line 17 Script php artisan clear-compiled handling the pre-update-cmd event returned with error code 255 – user2984757 Dec 07 '19 at 23:33

2 Answers2

3

Try with the below commands:

  1. composer update
  2. composer dump-autoload
Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Pushprajsinh Chudasama
  • 7,772
  • 4
  • 20
  • 43
0

This has been resolved.

When I ran composer update again, I got this error:

Could not scan for classes inside "tests/TestCase.php" which does not appear to be a file nor a folder

Realized I needed to re-upload/transfer the /app folder to the server. Afterwards, the errors went away.

user2984757
  • 29
  • 3
  • 8