cakephp 2.x插件在cakephp 3.x中不起作用

时间:2016-07-28 08:31:06

标签: plugins cakephp-2.0 cakephp-3.0

我已经开发了cakephp 2.x中的一个插件,并且它工作正常我正在管理y网站的基本配置,我已经做了以下事情,下面是代码

AppController中的

public $uses = array(
    'Configuration.Configuration',
); 

public function beforeFilter() {
        $this->Configuration->load();

}

之后在我的插件模型中我创建了函数

function load(){
    $settings = $this->find('all');
    foreach ($settings as $variable){
      Configure::write("{$variable['Configuration']['name']}",$variable['Configuration']['value']);
    }
}

然后在我的主管理员登录文件中使用配置

<?php 

    echo $this->Html->link($this->Html->image(Configure::read('Site.logo'),array('alt' => 'logo','title'=>Configure::read('Site.title'),'style'=>'max-width:148px;max-height:33px;')),array('controller'=>'users','action' => 'login','plugin'=>false), array('escape'=>false));

?>

它的工作正常,但当我使用cakephp 3.x的这个过程时,它的错误

Error: Class 'Configure' not found
File E:\xampp\htdocs\cakephp\src\Template\Layout\login.ctp
Line: 67 
plesae告诉我如何解决这个问题以及问题是什么

1 个答案:

答案 0 :(得分:0)

是的,CakePHP 3在文件结构和名称空间使用方面带来了许多重大变化。所以在2.x中开发的任何插件都不能在3.x中运行

为此,您必须参考迁移指南文档。 http://book.cakephp.org/3.0/en/appendices/3-0-migration-guide.html

CakePHP还提供升级工具,对您有所帮助。 https://github.com/cakephp/upgrade

由于