laravel 中不存在内核

Kernel does not exist in laravel

我已经在 laravel 中开发了项目,我正在我的本地计算机上设置它,但是在 运行 php artisan serve 之后我收到了这个错误

PHP Fatal error:  Uncaught ReflectionException: Class App\Console\Kernel does not exist in C:\xampp\htdocs\translate\vendor\laravel\framework\src\Illuminate\Container\Container.php:788

我不知道哪里出了问题,但我已经尝试了我在互联网上找到的所有方法

composer update
composer dump-autoload
composer self-update
php artisan config:clear
php artisan cache:clear
该命令的

none 对我有用

检查 app/Console 文件夹中是否有此文件

<?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 = [
        //
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        /*$schedule->command('users:update')->everyMinute();
        $schedule->command('servers:update')->everyMinute();*/
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

您必须 运行 composer install 才能安装新的依赖项。

既然你提到你的其他 artisan 命令有问题,请手动删除 bootstrap->cache 文件夹中的所有内容,当然 .gitignore 文件除外,然后 运行 php artisan optimize

这样您的 "corrupted" 缓存将被重新创建和配置。

您必须做的第一件事是确保您的 artisan 命令正常工作,所以我建议首先进行缓存修复。然后你可以 运行 你在问题中提到的作曲家命令。