Cakephp中缺少插件错误
我正在cakephp2.5中开发一个站点。我有两个插件Cakephp中缺少插件错误,cakephp,cakephp-2.5,Cakephp,Cakephp 2.5,我正在cakephp2.5中开发一个站点。我有两个插件Webmaster和debugKit。当我写作时 CakePlugin::load('Webmaster', array('bootstrap' => false, 'routes' => false)); CakePlugin::load('webmaster'); CakePlugin::load( 'DebugKit'); 该站点在本地系统上正常工作,但在live server上无法正常工作。但是,如果我删除上面的网站管理
Webmaster
和debugKit
。当我写作时
CakePlugin::load('Webmaster', array('bootstrap' => false, 'routes' => false));
CakePlugin::load('webmaster');
CakePlugin::load( 'DebugKit');
该站点在本地系统上正常工作,但在live server上无法正常工作。但是,如果我删除上面的网站管理员
之一,则会在本地系统和live上显示错误
Error: The application is trying to load a file from the webmaster plugin
Error: Make sure your plugin webmaster is in the app\Plugin directory and was loaded
我也试过了,但运气不好。挣扎了两天。也看到了这些链接
这是我的网站管理员AppController
<?php
App::uses('AppController', 'Controller');
class WebmasterAppController extends AppController{
public $theme= "beyond";
//public $layout=NULL;
public function beforeFilter(){
//$this->Auth->allow('login');
$this->Auth->loginAction= array('controller'=>'users', 'action'=>'login');
$this->Auth->loginRedirect= array('controller'=>'users', 'action'=>'index');
$this->Auth->loginError= 'Invalid Email/Password!';
$this->Auth->authError= 'You are not authorised to access!';
$this->Auth->logoutRedirect= array('controller'=>'users', 'action'=>'login');
AuthComponent::$sessionKey = 'Auth.Webmaster';
//we don't need to load debug kit
$this->Components->unload('DebugKit.Toolbar');
parent::beforeFilter();
}
class AppController extends Controller{
public $cakeDescription = "CakePhp | ";
public $theme = "alpus";
public $ext = 'html';
public $helpers = array('NiceForms', 'coolFun');
public $components = array(
'DebugKit.Toolbar',
'Common',
'Session',
'Auth' => array(
'loginRedirect' => array(
'controller' => 'pages',
'action' => 'dashboard'
),
'logoutRedirect' => array(
'controller' => 'users',
'action' => 'login',
),
'authenticate' => array(
'Form' => array(
'passwordHasher' => 'Blowfish',
'fields' => array('username' => 'email')
)
),
'sessionKey' => 'Admin'
)
);
public function beforeFilter(){
if (isset($this->params['prefix']) && $this->params['prefix'] == 'admin') {
$this->theme = 'smart';
$this->Auth->loginAction = array('controller' => 'users', 'action' => 'admin_login', 'plugin' => false);
}
$this->Auth->allow('register');
}
}
编辑1:对于CakePHP3.0,我们可以使用 公共函数beforeFilter(事件$Event){ $this->Auth->sessionKey='Auth.User' }
在AppController.php中为前端和后端设置不同的sessionKey。为什么对同一个插件有多个加载调用?每个插件应该只有一个 尽管如此,请注意大小写,第二个
CakePlugin::load()
调用使用webmaster
而不是webmaster
。插件名称应该以大写字母开头,就像对应的目录名一样
本地文件系统很可能不区分大小写,因此即使大小写不匹配,它也可以找到插件目录
更新看起来我一开始搞错了,如果CakePHP会告诉你加载插件
webmaster
,而你还没有添加CakePlugin::load('webmaster')
调用,那么你一定在代码的其他地方使用了小写的webmaster
。我不想加载两次,但正如我在问题中提到的,每当我删除其中一个插件时,它也会显示本地系统缺少插件的错误。然而,在实时服务器上,它显示应用程序正试图从网站管理员插件加载文件。嗯@RNKushwaha,您的问题措辞并没有真正帮助理解它。与您的评论相同,错误消息听起来好像是说Webmaster
,而不是Webmaster
。正如我所说,大小写很重要,因此请确保您在任何地方都正确使用网站管理员,并删除多余的load()
呼叫。感谢@ndm的回答,并为我的英语不好表示歉意。但是,请告诉我添加这一行CakePlugin::load('webmaster')代码>而不是CakePlugin::load('Webmaster')代码>和我用站长
到处不是`站长。不需要道歉@RNKushwaha,我只是想指出,理解你说的话并不那么容易。无论如何,如果CakePHP告诉您在没有添加CakePlugin::load('webmaster')
调用的情况下加载插件webmaster
,那么您必须在代码中的某个地方使用小写的webmaster
。链接站点上的错误显然源于加载('webmaster')
调用,请将其删除!如果你仍然收到一个缺少插件的错误,那么请用确切的stacktrace更新你的问题(包括上下文>点击链接)。正如你所说的大小写是一个问题,实际上我在UsersController中使用的是webmaster
,而不是webmaster
。请在你的答案中加上这一行,我会把它标记为接受答案。谢谢