2015-10-23 07:24
浏览 62

CakePHP 3.1 - 插件缺少帮助程序错误

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:

  1. I created the plugin structure described by the cookbook in:
  2. 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()){
            // ...
  3. I added the following line in config/bootstrap :


    these in View/AppView:

    public function initialize()

    and this one in Controller/AppController:

    public $helpers = ['Easyui.Easyui'];
  4. 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?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douzi2785
    douzi2785 2015-10-23 12:12

    You need to add the path to your composer.json so that the autoloader can pick them up. See

    "autoload": {
        "psr-4": {
            "Easyui\\": "./plugins/Easyui/src",
    "autoload-dev": {
        "psr-4": {
            "Easyui\\Test\\": "./plugins/Easyui/tests",

    I recommend you to always read the whole chapter and not only partial excerpts of it. ;)

    点赞 评论