将cakephp从1.3升级到2.0后出现问题

时间:2014-02-25 04:04:14

标签: php cakephp upgrade

当我将cakephp从1.3升级到2.0时,我遇到了错误。 我没有使用任何插件。

我尝试添加CakePlugin::load('User');和CakePlugin :: loadAll();在bootstrap.php文件中。但仍然得到同样的错误。

请求帮助。

缺少插件

Error: The application is trying to load a file from the User plugin

Error: Make sure your plugin User is in the app/Plugin directory and was loaded

<?php
CakePlugin::load('User');

加载所有插件:如果您希望一次加载所有插件,请在app / Config / bootstrap.php文件中使用以下行

enter code here CakePlugin :: LOADALL();

注意:如果要自定义此错误消息,请创建app / View / Errors / missing_plugin.ctp 堆栈跟踪

CORE/Cake/Core/App.php line 365 → CakePlugin::path(string)
CORE/Cake/Core/App.php line 226 → App::pluginPath(string)
CORE/Cake/Core/App.php line 547 → App::path(string, string)
[internal function] → App::load(string)
[internal function] → spl_autoload_call(string)
CORE/Cake/Utility/ClassRegistry.php line 145 → class_exists(string)
CORE/Cake/View/Helper/FormHelper.php line 163 → ClassRegistry::init(string, boolean)
CORE/Cake/View/Helper/FormHelper.php line 196 → FormHelper->_getModel(string)
CORE/Cake/View/Helper/FormHelper.php line 346 → FormHelper->_introspectModel(string, string)
APP/View/Users/profile.ctp line 49 → FormHelper->create(string, array)
CORE/Cake/View/View.php line 929 → include(string)
CORE/Cake/View/View.php line 891 → View->_evaluate(string, array)
CORE/Cake/View/View.php line 460 → View->_render(string)
CORE/Cake/Controller/Controller.php line 952 → View->render(null, null)
CORE/Cake/Routing/Dispatcher.php line 192 → Controller->render()
CORE/Cake/Routing/Dispatcher.php line 160 → Dispatcher->_invoke(UsersController, CakeRequest, CakeResponse)
APP/webroot/index.php line 108 → Dispatcher->dispatch(CakeRequest, CakeResponse)

如果APP / View / Users / profile.ctp

,则行号49
   <?php echo $this->Form->create("User.user_profile_data", array("action" => "/users/profile")); ?>

用户模型

<?php
 class User extends AppModel {
var $name = 'users';
var $hasMany = array('Group' =>
    array(
        'className' => 'Group',
        'foreignKey' => 'user_id',
        'dependent' => true,
        ));

function changeDataSource($newSource) {
    parent::setDataSource($newSource);
    parent::__construct();
}

function validateLogin($data) {

     $user = $this->find('first', array('conditions' => array('username' => $data['User']['username'], 'password' => $data['User']['password'], 'status' => 'A')));


    if (empty($user) == false)
        return $user;
    return false;
   }
  }
 ?>

1 个答案:

答案 0 :(得分:0)

在不使用任何插件时,只需删除任何插件加载。然后修改你的第49行:

<?php echo $this->Form->create("User", array("action" => "/users/profile")); ?>

您设置它的方式User.blahBlah告诉CakePHP将其视为插件。

供参考:http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html