Zend Framework Create Custom View Helper?

2019-08-14 23:44发布

问题:

I have tried multiple fixes but none have worked.
I am getting this error:

Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'AddCss' was not found in the registry; used paths: Zend_View_Helper_: Zend/View/Helper/:/Users/cgunnels/dev/git/rove-git/application/views/helpers/' in /usr/local/zend/share/ZendFramework/library/Zend/Loader/PluginLoader.php:412 Stack trace: #0 /usr/local/zend/share/ZendFramework/library/Zend/View/Abstract.php(1182): Zend_Loader_PluginLoader->load('AddCss') #1 /usr/local/zend/share/ZendFramework/library/Zend/View/Abstract.php(618): Zend_View_Abstract->_getPlugin('helper', 'addCss') #2 /usr/local/zend/share/ZendFramework/library/Zend/View/Abstract.php(344): Zend_View_Abstract->getHelper('addCss') #3 /Users/cgunnels/dev/git/rove-git/application/layouts/scripts/layout.phtml(6): Zend_View_Abstract->__call('addCss', Array) #4 /Users/cgunnels/dev/git/rove-git/application/layouts/scripts/layout.phtml(6): Zend_View->addCss(Array) #5 /usr/local/zend/share/ZendFramework/library/Zend/View.php(108): include('/Users/cgunnels...') #6 /usr in /usr/local/zend/share/ZendFramework/library/Zend/Controller/Plugin/Broker.php on line 336

this is my class:

 class Zend_View_Helper_Css extends Zend_View_Helper_Abstract {
      public function css() {
        die("test");
      }
    }

I followed the instructions on this page http://framework.zend.com/manual/en/zend.view.helpers.html and it doesn't work.

I also added this to my application.ini:

resources.view.helperPath = APPLICATION_PATH "/views/helpers"

Please help me out, thanks

回答1:

answer provided by author:

I fixed it. So the filename was CssHelper.php I changed it to Css.php and it worked. – chris gunnels