I created a plugin, but didnt baked it, that basicly has a helper which I want to use in the application. When running the index.php I get the following error:
Fatal error: [Cake\View\Exception\MissingHelperException] Helper class EasyuiHelper could not be found.
#0 C:\xampp\htdocs\myKMG_3\vendor\cakephp\cakephp\src\Core\ObjectRegistry.php(91): Cake\View\HelperRegistry->_throwMissingClassError('Easyui', 'Easyui') #1 C:\xampp\htdocs\myKMG_3\vendor\cakephp\cakephp\src\View\View.php(1001): Cake\Core\ObjectRegistry->load('Easyui.Easyui', Array) #2 C:\xampp\htdocs\myKMG_3\src\View\AppView.php(40): Cake\View\View->loadHelper('Easyui.Easyui') #3 C:\xampp\htdocs\myKMG_3\vendor\cakephp\cakephp\src\View\View.php(335): App\View\AppView->initialize() #4 C:\xampp\htdocs\myKMG_3\vendor\cakephp\cakephp\src\View\ViewBuilder.php(350): Cake\View\View->__construct(Object(Cake\Network\Request), Object(Cake\Network\Response), Object(Cake\Event\EventManager), Array) #5 C:\xampp\htdocs\myKMG_3\vendor\cakephp\cakephp\src\View\ViewVarsTrait.php(119): Cake\View\ViewBuilder->build(Array, Object(Cake\Network\Request), Object(Cake\Network\Response), Object(Cake\Event\EventManager)) #6 C:\xampp\htdocs\myKMG_ in C:\xampp\htdocs\myKMG_3\vendor\cakephp\cakephp\src\Error\ErrorHandler.php on line 156
I followed this procedure to create the plugin:
- I created the plugin structure described by the cookbook in: http://book.cakephp.org/3.0/en/plugins.html#creating-your-own-plugins
-
I created the helper for the plugin in
plugins/Easyui/scr/View/Helper EasyuiHelper.php:
namespace Easyui\View\Helper; use Cake\View\Helper; class EasyuiHelper extends Helper { public function linkButton($id_image='imgLinkButton', $optionsImg=array()){ // ... } }
-
I added the following line in config/bootstrap :
Plugin::load('Easyui');
these in
View/AppView
:public function initialize() { parent::initialize(); $this->loadHelper('Easyui.Easyui'); }
and this one in
Controller/AppController
:public $helpers = ['Easyui.Easyui'];
-
I use the helper in default layout file:
$this->Easyui->linkButton('imgPrint', array('iconCls'=>'icon-print', 'onClick'=>'window.print()'));
Where did I go wrong? Did I miss anything?