【问题标题】:Issue after upgrading cakephp from 1.3 to 2.0将 cakephp 从 1.3 升级到 2.0 后的问题
【发布时间】:2014-03-27 02:15:01
【问题描述】:

当我将 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 hereCakePlugin::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;
   }
  }
 ?>

【问题讨论】:

  • 你能在第 49 行附近添加 APP/View/Users/profile.ctp 的代码吗?
  • 编辑您的原始帖子并注意格式。同时添加您的User 模型。

标签: php cakephp upgrade


【解决方案1】:

当您不使用任何插件时,只需删除任何插件负载。然后修改你的第 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

【讨论】:

  • 太棒了!它是固定的。谢谢你sємsєм :)
  • @VipinPA 欢迎您。不要忘记将其设置为答案并投票。 :)
  • 我现在不能投票了
猜你喜欢
  • 1970-01-01
  • 2012-07-14
  • 1970-01-01
  • 2016-06-09
  • 1970-01-01
  • 1970-01-01
  • 2011-09-19
  • 1970-01-01
  • 2011-02-17
相关资源
最近更新 更多