拉拉维尔错误'ReflectionException' - 'Class AppHttpKernel does not exist'



我一年前在学校开发了一个小型旅行项目,当时我正试图上线,但遇到了一些问题。在把整个项目上传到我的主机服务服务器上后,我的浏览器和SSH shell上都出现了这些错误。

致命错误:未捕获的异常'ReflectionException'与消息'类AppHttp内核不存在'在/home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php:779#0/home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(779): ReflectionClass->__construct('AppHttpKernel') #1/home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(659):照亮ContainerContainer->build('AppHttpKernel', Array) #2/home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(644):照亮ContainerContainer->make('AppHttpKernel', Array) #3/home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php(229):照亮FoundationApplication->make('AppHttpKernel', Array) #4/home/clients/ffa41f94063/home/clients/ffa41f94063541f86a0fe6602a73caa1/myforms/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 779

我想这可能与我的命名空间配置有关,因为我还没有完全理解。

这是我的作曲家。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
  • 时,我得到了错误

请告诉我,如果我应该张贴另一个文件,可能是有用的。

提前感谢您的帮助。

json变化:

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

:

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

在服务器上,在源目录下,运行composer update,然后运行composer dump-autoload

PSR-4在Laravel中查找相对于项目根目录的命名空间

检查console/kernel.php是否在app -文件夹内,如果不是,它可能在laravelApp内。

如果是,将console/kernel.php移动到app -folder.

在我的例子中,composer。Json中缺少结束"{}"的右括号,并且"psr-4"行在错误的Json段中。

  1. 检查作曲家。为了正确对齐"psr-4",它应该是"autoload"部分的子部分。
  2. 删除供应商
  3. 作曲家安装

{
	"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"
	}
}

在这里的其他答案的帮助下,我意识到我刚刚错过了从Laravel 5.5手动更新到5.7的更改

的作曲家。我在自动加载块中漏掉了这个:

"autoload": {
    "psr-4": {
        "App\": "app/"
    },
    ...
},

如果你正在使用版本控制,在你的开发机器上运行composer update来更新composer.lock。然后在生产服务器上,只需要运行composer install

相关内容

  • 没有找到相关文章

最新更新