简体   繁体   English

Laravel:致命错误:未捕获反射异常:Class App\Http\Kernel 不存在

[英]Laravel : Fatal error: Uncaught ReflectionException: Class App\Http\Kernel does not exist

so last night i was doing some codes like always(normal class/function code not at all related to kernel or anything) and everything was working perfectly, but today when i wanted to start my coding again this error happend:所以昨晚我一直在做一些代码(普通类/函数代码与 kernel 或任何东西完全无关)并且一切正常,但今天当我想再次开始我的编码时,发生了这个错误:

Fatal error: Uncaught ReflectionException:
Class App\Http\Kernel does not exist in H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php:809
Stack trace:
#0 H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php(809): ReflectionClass->__construct('App\\Http\\Kernel')
#1 H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php(691): Illuminate\Container\Container->build('App\\Http\\Kernel')
#2 H:\Hadi\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(796): Illuminate\Container\Container->resolve('App\\Http\\Kernel', Array, false)
#3 H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php(269): Illuminate\Foundation\Application->resolve('App\\Http\\Kernel', Array, false)
#4 H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php(805): Illuminate\Container\Container->Illuminate\Container\{closure}(Object(Illuminate\Foundation\Application), Array)
#5 H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php(691): I in H:\Hadi\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 811

OS: Windows 10操作系统:Windows 10

PHP Version: 7.4.9 PHP 版本:7.4.9

laravel version: 7.30.4 laravel 版本:7.30.4

what i already done by reading previous questions:我已经通过阅读以前的问题做了什么:

restore your old composer.lock file
Check composer.json for proper align of "psr-4" it should be child of "autoload" section.
Remove vendor
composer install

php artisan optimize:clear
php artisan config:cache
composer dump-autoload
composer update

Check if console/kernel.php is inside of app-folder,

this is my composer.json这是我的 composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "7.4.7",
        "anhskohbo/no-captcha": "^3.0",
        "artisaninweb/laravel-soap": "0.3.0.9",
        "econea/nusoap": "dev-master",
        "fideloper/proxy": "^4.0",
        "guzzlehttp/guzzle": "^6.5",
        "hootlex/laravel-friendships": "^1.0",
        "intervention/image": "^2.5",
        "irazasyed/telegram-bot-sdk": "^3.0",
        "laravel/framework": "^7.0",
        "laravel/helpers": "^1.2",
        "laravel/tinker": "^2.0",
        "laravel/ui": "2.0"
    },
    "require-dev": {
        "beyondcode/laravel-dump-server": "^1.0",
        "facade/ignition": "^2.0",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^4.1",
        "phpunit/phpunit": "^8.5"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true,
        "platform": {
            "php": "7.4.7"
        }
    },
    "extra": {
        "laravel": {
            "dont-discover": [
                "laravel/dusk"
            ]
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/"
        },
        "classmap": [
            "database/seeds",
            "database/factories"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

and this is my kernel这是我的 kernel

<?php

namespace App\Console;

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

class Kernel extends ConsoleKernel
{

    protected $commands = [

    ];

    protected function schedule(Schedule $schedule)
    {
        $schedule->call('App\Http\Controllers\ProductController@delete')->daily();
    }


    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

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

my App\Http\Kernel我的应用\Http\内核

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \App\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
        \App\Http\Middleware\TrimStrings::class,
        \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
        \App\Http\Middleware\TrustProxies::class,
    ];

    /**
     * The application's route middleware groups.
     *
     * @var array
     */
    protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            // \Illuminate\Session\Middleware\AuthenticateSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \App\Http\Middleware\Localization::class,
        ],

        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

    /**
     * The application's route middleware.
     *
     * These middleware may be assigned to groups or used individually.
     *
     * @var array
     */
    protected $routeMiddleware = [
        'auth' => \App\Http\Middleware\Authenticate::class,
        'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
        'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
        'can' => \Illuminate\Auth\Middleware\Authorize::class,
        'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
        'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
        'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
        'verified' => \Illuminate\Auth\Middleware\EnsureEmailIsVerified::class,
        'is.admin' => \App\Http\Middleware\IsAdmin::class,
        'locale' => \App\Http\Middleware\Localization::class,
        'ssl' => \App\Http\Middleware\ForceSSL::class,
    ];

    /**
     * The priority-sorted list of middleware.
     *
     * This forces non-global middleware to always be in the given order.
     *
     * @var array
     */
    protected $middlewarePriority = [
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\Authenticate::class,
        \Illuminate\Session\Middleware\AuthenticateSession::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        \Illuminate\Auth\Middleware\Authorize::class,
    ];
}

please help me sove this sudden problem请帮我解决这个突如其来的问题

First of all: check if file app/Http/Kernel.php is exists and it has correct namespace and class name (without any cyrilic or etc. characters):首先:检查文件app/Http/Kernel.php是否存在,它是否具有正确的命名空间和 class 名称(没有任何西里尔字符或其他字符):

<?php

// Should be 'App\Http'
namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

// Should be 'Kernel'
class Kernel extends HttpKernel
{
    //
}

If all seems correct - this should be a composer PSR-4 loading bug.如果一切看起来都是正确的——这应该是作曲家 PSR-4 加载错误。 Try to remove vendor directory and composer.lock file and run composer install尝试删除vendor目录和composer.lock文件并运行composer install

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Laravel错误:未捕获的ReflectionException:类App \\ Http \\ Kernel不存在 - Laravel Error : Uncaught ReflectionException: Class App\Http\Kernel does not exist Laravel错误未捕获异常'ReflectionException',消息'Class App \ Http \ Kernel不存在' - Laravel error Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist' Laravel 错误 &#39;ReflectionException&#39; - &#39;Class App\\Http\\Kernel 不存在&#39; - Laravel error 'ReflectionException' - 'Class App\Http\Kernel does not exist' 未捕获的ReflectionException:在/project/vendor/laravel/framework/src/Illuminate/Container/Container.php:721中不存在App \\ Http \\ Kernel类 - Uncaught ReflectionException: Class App\Http\Kernel does not exist in /project/vendor/laravel/framework/src/Illuminate/Container/Container.php:721 未捕获的异常 &#39;ReflectionException&#39; 带有消息 &#39;Class App\\Console\\Kernel does not exist&#39; - Uncaught exception 'ReflectionException' with message 'Class App\Console\Kernel does not exist' Laravel 5.1.11致命错误:消息为“类日志不存在”的未捕获异常“ Re​​flectionException” - Laravel 5.1.11 Fatal error: Uncaught exception 'ReflectionException' with message 'Class log does not exist' 致命错误:未捕获的 ReflectionException:Class “env”不存在 - Fatal error: Uncaught ReflectionException: Class "env" does not exist 致命错误:未捕获的 ReflectionException:Class 配置不存在 - Fatal error: Uncaught ReflectionException: Class config does not exist Laravel-未捕获的ReflectionException:类日志不存在-配置错误 - Laravel - Uncaught ReflectionException: Class log does not exist - Config error ReflectionException类App \\ Http \\ Controllers \\ ContactController不存在Laravel 5.2 - ReflectionException Class App\Http\Controllers\ContactController does not exist Laravel 5.2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM