Zend framework Zend:自定义视图帮助程序

Zend framework Zend:自定义视图帮助程序,zend-framework,zend-view,Zend Framework,Zend View,我试图在项目中添加视图辅助对象,但出现以下错误: [Mon Apr 29 14:36:19 2013] [error] [client 10.0.0.26] PHP Fatal error: Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'LoggedInAs' was not found in the registry; used paths:\nMy_View_Hel

我试图在项目中添加视图辅助对象,但出现以下错误:

[Mon Apr 29 14:36:19 2013] [error] [client 10.0.0.26] PHP Fatal error:  Uncaught exception 'Zend_Loader_PluginLoader_Exception' with message 'Plugin by name 'LoggedInAs' was not found in the registry; used paths:\nMy_View_Helper_: /var/www/html/test-project/application/views/helpers/\nZend_View_Helper_: Zend/View/Helper/:/var/www/html/test-project/application/views/helpers/' in /usr/share/php/Zend/Loader/PluginLoader.php:412\nStack trace:\n#0 /usr/share/php/Zend/View/Abstract.php(1182): Zend_Loader_PluginLoader->load('LoggedInAs')\n#1 /usr/share/php/Zend/View/Abstract.php(618): Zend_View_Abstract->_getPlugin('helper', 'loggedInAs')\n#2 /usr/share/php/Zend/View/Abstract.php(344): Zend_View_Abstract->getHelper('loggedInAs')\n#3 /var/www/html/test-project/application/layouts/scripts/layout.phtml(16): Zend_View_Abstract->__call('loggedInAs', Array)\n#4 /var/www/html/test-project/application/layouts/scripts/layout.phtml(16): Zend_View->loggedInAs()\n#5 /usr/share/php/Zend/View.php(108): include('/var/www/html/t...')\n#6 /usr/share/php/Zend/View/Abstract.php(888): Zend_View->_run('/var/www/html/ in / /usr/share/php/Zend/Controller/Plugin/Broker.php on line 336
application/views/helpers/LoggedInAs.php

class My_View_Helper_LoggedInAs extends Zend_View_Helper_Abstract
{
    public function loggedInAs()
    {
        //code
    }
}
应用程序/configs/application.ini

resources.view[]=
resources.view.helperPath.My_View_Helper = APPLICATION_PATH "/views/helpers"
应用程序/layouts/scripts/layout.phtml

echo $this->loggedInAs();
关于stackoverflow还有其他几个问题,但这些问题对我来说并不适用

编辑1: Tim Fountain回答后,将Zend_View_Helper_LoggedInAs更改为My_View_Helper_LoggedInAs 编辑2:
完全错误

类名应该是
My_View\u Helper\u LoggedInAs
,因为这是您在application.ini中声明的名称空间。Zend命名空间仅适用于ZF类。

类名应为
My_View\u Helper\u LoggedInAs
,因为这是您在application.ini中声明的命名空间。Zend名称空间仅用于ZF类。

我用一个奇怪的解决方案修复了它,因为我在internet上找不到类似的东西。
我刚刚添加了
我用一个奇怪的解决方案修复了它,因为我在互联网上找不到类似的东西。

我刚刚添加了
您提供的答案似乎没有多大意义,如果您说您添加了
您提供的答案似乎没有多大意义,如果您说您添加了
您可以编辑您的问题以包含完整的错误吗?它还应该列出它尝试的路径和名称空间,老实说,您发布的所有内容看起来都很好。您是否可以再次检查该类的文件名是否确实为LoggedInAs.php(区分大小写)?您是否可以编辑您的问题以包含完整的错误?它还应该列出它尝试的路径和名称空间,老实说,您发布的所有内容看起来都很好。你能再检查一下这个类的文件名是否确实是LoggedInAs.php(区分大小写)吗?是的,我知道,愚蠢的是我没有想到它。我已经用PHP编写代码好几年了,但是现在我很困惑,因为我正在学习ZF;)不要让ZF把您弄糊涂了,它只是PHP。(暗示):)是的,我知道,愚蠢的是我没有想到它。我已经用PHP编写代码好几年了,但是现在我很困惑,因为我正在学习ZF;)不要让ZF把您弄糊涂了,它只是PHP。(提示):)
//excerpt from application.ini
resources.view.helperPath = APPLICATION_PATH "/views/helpers"
resources.view.helperPathPrefix = "My_View_Helper"
//bootstrap.php
protected function _initView()
    {
        //Initialize view
        $view = new Zend_View();
        //add custom view helper path
        $view->addHelperPath(APPLICATION_PATH . '/../library/My/View/Helper');
        //add custom script path for partials
        $view->addScriptPath(APPLICATION_PATH . '/../library/My/View/Scripts/');
        //set css includes, path is relative to /public
        $view->headlink()->setStylesheet('/bootstrap/css/bootstrap.css');
        //add javascript files, path is relative to /public
        $view->headScript()->setFile('/bootstrap/js/jquery.min.js');
        $view->headScript()->appendFile('/bootstrap/js/bootstrap.min.js');
        //add it to the view renderer
        $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper(
                'ViewRenderer');
        $viewRenderer->setView($view);
        //Return it, so that it can be stored by the bootstrap
        return $view;
    }