Laravel 错误 'ReflectionException' - 'Class App\Http\Kernel does not exist'
Laravel error 'ReflectionException' - 'Class App\Http\Kernel does not exist'
我试图开始一个 laravel 项目,这是我一年前在学校开发的,但我 运行 遇到了一些问题。
将整个项目上传到我的托管服务服务器后,我的浏览器和 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
我觉得可能和我的命名空间配置有关,因为我还没有完全理解。
这是我的 composer.json 文件:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.5.*",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "myforms/app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
我已经做了什么:
- 删除 /vendor 并使用
composer install
进行新安装
composer dump-autoload
composer update
顺便说一句,当我插入 composer update
时出现错误
如果我应该 post 另一个可能有用的文件,请通知我。
在此先感谢您的帮助。
在composer.json中更改:
"psr-4": {
"App\": "myforms/app/"
}
至:
"psr-4": {
"App\": "app/"
}
在服务器上,在您的源目录中,运行 composer update
然后 composer dump-autoload
Laravel 中的 PSR-4 查找相对于项目根目录的名称空间
在我的例子中 composer.json 缺少正确的括号关闭“{ }”并且带有 "psr-4" 的行在错误的 json 段中。
- 检查 composer.json 是否正确对齐 "psr-4" 它应该是 "autoload" 部分的子部分。
- 删除供应商
- 作曲家安装
好的
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.5.*",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "myforms/app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
检查 console/kernel.php
是否在 app
文件夹内,如果不在,它可能在您的 laravelApp
内。
如果是,请将 console/kernel.php
移动到 app
- 文件夹。
我试图开始一个 laravel 项目,这是我一年前在学校开发的,但我 运行 遇到了一些问题。 将整个项目上传到我的托管服务服务器后,我的浏览器和 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
我觉得可能和我的命名空间配置有关,因为我还没有完全理解。
这是我的 composer.json 文件:
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.5.*",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "myforms/app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
我已经做了什么:
- 删除 /vendor 并使用
composer install
进行新安装
composer dump-autoload
composer update
顺便说一句,当我插入composer update
时出现错误
如果我应该 post 另一个可能有用的文件,请通知我。
在此先感谢您的帮助。
在composer.json中更改:
"psr-4": {
"App\": "myforms/app/"
}
至:
"psr-4": {
"App\": "app/"
}
在服务器上,在您的源目录中,运行 composer update
然后 composer dump-autoload
Laravel 中的 PSR-4 查找相对于项目根目录的名称空间
在我的例子中 composer.json 缺少正确的括号关闭“{ }”并且带有 "psr-4" 的行在错误的 json 段中。
- 检查 composer.json 是否正确对齐 "psr-4" 它应该是 "autoload" 部分的子部分。
- 删除供应商
- 作曲家安装
好的
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"laravel/framework": "5.0.*",
"illuminate/html": "5.*",
"barryvdh/laravel-dompdf": "0.5.*",
"guzzlehttp/guzzle": "~4.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpspec/phpspec": "~2.1"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "myforms/app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-install-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-update-cmd": [
"php artisan clear-compiled",
"php artisan optimize"
],
"post-create-project-cmd": [
"php -r \"copy('.env.example', '.env');\"",
"php artisan key:generate"
]
},
"config": {
"preferred-install": "dist"
}
}
检查 console/kernel.php
是否在 app
文件夹内,如果不在,它可能在您的 laravelApp
内。
如果是,请将 console/kernel.php
移动到 app
- 文件夹。