0

I am developing a site in cakephp2.5. I have two plugin Webmaster and debugKit. When I write

CakePlugin::load('Webmaster', array('bootstrap' => false, 'routes' => false));
CakePlugin::load('webmaster');
CakePlugin::load( 'DebugKit');

The site works correctly on local system but not on live server. However if I remove one of the above Webmaster it shows error on local system and also on 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

I also tried but no luck. Struggling from 2 days. Also seen these links link1 link2

Here is my WebmasterAppController

<?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();
}

}

And here is AppController

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');
}

}

Edit 1:
For cakephp 3.0 we can use

public function beforeFilter(Event $event) {

$this->Auth->sessionKey ='Auth.User';

}

in AppController.php to set different sessionKey for frontend and backend.

Community
  • 1
  • 1
RN Kushwaha
  • 2,081
  • 3
  • 29
  • 40

1 Answers1

1

Why do you have multiple load calls for the same plugin anways? There should be only one per plugin!

That being said, mind your casing, the second CakePlugin::load() call uses webmaster instead of Webmaster. Plugin names should start with an uppercased letter, just like the corresponding directory name.

Your local filesystem is most probably case insensitive, so it can find the plugin directory even though the casing doesn't match.

Update It looks like I intially got you wrong, if CakePHP would tell you to load the plugin webmaster without you already having added a CakePlugin::load('webmaster') call, then you must have used the lowercased webmaster somewhere else in your code.

ndm
  • 59,784
  • 9
  • 71
  • 110
  • I dont want to load it twice, but as I mentioned in my question whenever I remove one o them it show me error for missing plugin on local system too. However on live server it shows application is trying to load file from Webmaster plugin. – RN Kushwaha Nov 18 '14 at 04:36
  • Well @RNKushwaha, your questions wording didn't really help to make it understandable. Same with your comment, it sounds as if the error message would say `Webmaster`, not `webmaster`. As I said, casing is important, so please make sure you are properly using `Webmaster` everywhere, and remove the surplus `load()` call. – ndm Nov 18 '14 at 05:00
  • Thanks @ndm for your answer and apologies for my bad english. However cake tell me to add this line `CakePlugin::load('webmaster');` instead of `CakePlugin::load('Webmaster');` and I used `Webmaster` everywhere not `webmaster. [See here](http://aryan022.byethost13.com/cakephp/) – RN Kushwaha Nov 18 '14 at 05:50
  • No need to apologize @RNKushwaha, I just wanted to point out that it's not that easy to understand what you are saying. Anyhow, if CakePHP would tell you to load the plugin `webmaster` without you already having added a `CakePlugin::load('webmaster')` call, then you must have used the lowercased `webmaster` somewhere in your code. The error on your linked site clearly stems from the `load('webmaster')` call, please remove it! And if you then still receive a missing plugin error, then please update your question with the exact stacktrace (including the context > click on the links). – ndm Nov 18 '14 at 06:15
  • 1
    As you said the casing was a problem, actually I was using `webmaster` instead of `Webmaster` in UsersController. Please add this line in your answer and I'll mark it as accepted answer. Thanks – RN Kushwaha Nov 18 '14 at 17:47
  • Just wanted to ask, is that mean you are using two plugin named webmaster and Webmaster? Is it the same plugin or different plugin. If it is same plugin, why you need to use 2 same plugin on one application? – Nizam Nov 19 '14 at 05:33
  • As a I mentioned above its just a single plugin Webmaster. I used webmaster instead of Webmaster. I didn't followed cakephp naming convention hence it was showing error that plugin is missing. Now its working fine. – RN Kushwaha Nov 20 '14 at 04:42