CakePHP迁移3.9到4.2未定义的方法CakeCorePlugin::load()



我正在将CakePHP从3.9版本迁移到4.2版本,我看到了错误:

Exception: Call to undefined method CakeCorePlugin::load()
config/bootstrap_cli.php

下一行的

Plugin::load('Bake');

似乎CorePlugin没有被正确导入。在config/bootstrap_cli.php的前面,我有:

use CakeCorePlugin;

也许它没有被正确安装?我的composer.json包含以下内容:

"require": {                                                                                        
"php": ">=5.4.16",                                                                              
"cakephp/cakephp": "^4.0",                                                                      
"mobiledetect/mobiledetectlib": "2.*",                                                          
"cakephp/migrations": "~3.0",                                                                   
"cakephp/plugin-installer": "^1.0",                                                             
"phpunit/phpunit": "^8.0",                                                                      
"cakephp/bake": "^2.0",                                                                         
"cakephp/core": "^4.0"                                                                          
},
"autoload": {                                                                                       
"psr-4": {                                                                                      
"App\": "src"                                                                              
}                                                                                               
},                                                                                                  
"autoload-dev": {                                                                                   
"psr-4": {                                                                                      
"App\Test\": "tests",                                                                     
"Cake\Test\": "./vendor/cakephp/cakephp/tests"                                            
}                                                                                               
},                                                                                                  
"scripts": {                                                                                        
"post-install-cmd": "App\Console\Installer::postInstall",                                     
"post-autoload-dump": "Cake\Composer\Installer\PluginInstaller::postAutoloadDump"            
},

从CakePHP的v4版本开始,没有这样的方法。您应该在升级之前检查弃用消息:v3.9上一个版本的代码为您的问题保留了一条重要消息:

@deprecated 3.7.0此方法将在4.0.0中删除。使用Application::addPlugin()代替。

最新更新