gpt4 book ai didi

php - 调用未定义的方法 App\Console\Kernel::load() - Laravel 5.4

转载 作者:行者123 更新时间:2023-12-03 21:21:37 25 4
gpt4 key购买 nike

我将我的应用程序从 5.5 to 5.4 降级当我运行 php artisan serve 时出现此错误

Call to undefined method App\Console\Kernel::load() - Laravel 5.4



查看其他解决方案,我运行 composer dump-autoload解决此问题,但问题仍然存在。同样的错误。我真的不知道这是否是由我在下面发布的 composer.json 文件中的包引起的

我现在能做些什么来解决这个问题?

提前致谢

Composer.Json
{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": ">=5.6.4",
"barryvdh/laravel-dompdf": "0.8.*",
"fideloper/proxy": "~4.0",
"guzzle/guzzle": "~3.0",
"laravel/framework": "5.4.*",
"laravel/passport": "^3.0",
"laravel/tinker": "~1.0",
"laravelcollective/html": "~5.0",
"maatwebsite/excel": " ~2.1.0",
"pda/pheanstalk": "~2.0",
"picqer/php-barcode-generator": "^0.2.0",
"spatie/laravel-permission": "^2.12",
"yajra/laravel-datatables-oracle": "~8.0"
},
"require-dev": {
"filp/whoops": "~2.0",
"nunomaduro/collision": "~1.1",
"fzaninotto/faker": "~1.4",
"mockery/mockery": "~1.0",
"phpunit/phpunit": "~7.0",
"symfony/thanks": "^1.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories",
"app/commands",
"app/models",
"app/database/seeds",
"app/tests/TestCase.php"
],
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}

最佳答案

问题是您没有确保将代码更新为与 Laravel 5.4 兼容。

Kernel.php Laravel 5.5+ 附带的样板文件

$this->load(__DIR__.'/Commands');

此命令是在 5.5 中添加的,用于自动检测 app/Console/Commands 目录中的任何命令。

为了让此代码在 5.4 中工作,您需要删除该行并在 protected $commands = [ ] 下手动注册所有命令。数组在同一个文件中。
load的源代码在 https://github.com/laravel/framework/blob/5.5/src/Illuminate/Foundation/Console/Kernel.php#L196如果你想尝试适应它并把它放在你自己的 Kernel.php

关于php - 调用未定义的方法 App\Console\Kernel::load() - Laravel 5.4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53293830/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com