1
votes

I have created a helper "SideNavbarHelper.php" in {appname}/plugins/UsefulHelpers/src/View/Helper, and I am trying to set helper in beforeRender in AppController, but I got following error.

Error: UsefulHelpers.SideNavbarHelper could not be found.

beforeRender in AppController.php

public function beforeRender(Event $event) {
    parent::beforeRender($event);
    $this->helpers["Navbar"]  =  ["className"=>"UsefulHelpers.SideNavbar"];
}

SideNavbarHelper.php

namespace UsefulHelpers\View\Helper;
use Cake\View\Helper;
class SideNavbarHelper extends Helper {    
    public $helpers = ["Html"];
    public function defaultNavbar() {
        //some code here...
    }
}

I have confirmed that the plugin in loaded in bootstrap.php. Why am I getting the error?

1
have you loaded the plugin? - Sougata Bose
Yes, I loaded it in bootstrap.php. I confirmed it is correctly loaded because if I change the plugin name which does not exists, then the error message changes. - hitochan
set namespace & use?? - Sougata Bose
yes. Actually the answer below solved my problem. Anyways, thank you very much. - hitochan
OP, did it work for you? I've been trying to make my Helper work since a week ago, and I was starting to suspect that cakephp-3.0 had some bug. - Gui Imamura

1 Answers

0
votes

You need to make sure there is an autoloader setup for your plugin classes. Please refer this section in the documentation:

http://book.cakephp.org/3.0/en/plugins.html#autoloading-plugin-classes