CakePHP从3.9到4.2的迁移未定义的方法Cake\Core\Plugin::load()

mo49yndu  于 2022-11-12  发布在  PHP
关注(0)|答案(1)|浏览(123)

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

Exception: Call to undefined method Cake\Core\Plugin::load()

config/bootstrap_cli.php中的以下行上

Plugin::load('Bake');

看起来CorePlugin没有正确导入。在config/bootstrap_cli.php的前面,我有:

use Cake\Core\Plugin;

也许它没有被正确安装?我的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"            
    },
6ojccjat

6ojccjat1#

从CakePHP v4开始,就没有这样的方法了。在升级之前,你应该检查是否有过时的消息:v3.9最新版本中的代码为您的问题提供了一条重要信息:
@deprecated 3.7.0此方法将在4.0.0中移除。请改用Application::addPlugin()。

相关问题