doushiposong30622 2014-04-02 15:13
浏览 23
已采纳

CakePHP中第三方视图助手的正确位置是什么?

I made a view helper in my CakePHP project, but I want to publish it for others to use.

In my own project, it's in the /app/View/Helper/ directory. However I'm uncertain where it should go when other people use it.

Should it be in

/Vendor/

/Vendor/View/Helper/

or something like that? In this case, will it automatically be loaded like it does with normal view helpers or do I need to call

App::import('Vendor', 'myhelperdir'.DS.'myhelper.php');

Should this call be made from the view itself, or from the controller?

Thanks!

  • 写回答

1条回答 默认 最新

  • douan6815 2014-04-02 15:59
    关注

    Put it on github.com and package it into a plugin, add a composer.json file as well to the repository. That's the most easy way people can add the plugin to their project and maintain the plugin.

    You can read this page how to create a plugin: http://book.cakephp.org/2.0/en/plugins.html#creating-your-own-plugins

    How plugin helpers are loaded is explained as well on this page. Example:

    public $helpers = ['PluginName.Helper'];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料