dongshijiao2363 2015-03-09 22:26
浏览 53

ZF 1.12自定义视图帮助程序 - 打开失败

I'm working on restructuring my Zend 1.12 project. I have a couple of view helpers:

  • OutputComplexForm.php
  • OutputDistributorsList.php

I put them in /application/views/helpers

Class names are

  • Zend_View_Helper_OutputComplexForm
  • Zend_View_Helper_OutputDistributorsList

As I understand if you have Zend_View_Helper prefix you don't need to add any configs to application.ini

Now, when I try to load any page (even those which don't use helpers) I receive error:

Message: Zend_Session::start() - /otms/vendor/zendframework/zendframework1/library/Zend/Loader.php(Line:134): Error #2 include_once(): Failed opening    'Zend/View/Helper/OutputComplexForm.php' for inclusion (include_path='/otms/application/../library:/otms/application/../library/phpseclib0.3.1:/otms/application/../library/Amazon:/otms/application/../library/USPS:/otms/application/../library/Composer:/otms/library:/otms/vendor/phpseclib/phpseclib/phpseclib:/otms/vendor/zendframework/zendframework1/library:.:/usr/share/php:/usr/share/pear') 

Did I miss something?

UPD

I've found out that error occurred after calling function

$startedCleanly = session_start(); //line 482

in file /Zend/Session.php. After this call property Zend_Session_Exception::$sessionStartError contains described error message. I still don't see connection between starting session and initialising view helper.

  • 写回答

1条回答 默认 最新

  • doucheng1944 2015-03-11 05:09
    关注

    For application-specific classes that you write - stuff that appears inside ./application/* - should typically not be in the Zend_ pseudo-namespace. Rather, they should be in the appnamespace, as configured in ./application/config/application.ini.

    The default namespace is 'Application_', so a view-helper called MyHelper would typically be stored in the file ./application/views/helpers/MyHelper.php:

    class Application_View_Helper_MyHelper extends Zend_View_Helper_Abstract
    {
        public function myHelper()
        {
            // do your stuff here
        }
    }
    

    Note that the class name is upper-camel-case MyHelper and the method is lower-camelcase myHelper().

    In your view, you can invoke your view-helper with:

    <?php
    
    $output = $this->myHelper();
    // Do something with $output
    

    With these conventions on namespace, class name, and file location/name, and invocation syntax, the View's plugin loader should be able find, load, and execute your view-helper method.

    评论

报告相同问题?

悬赏问题

  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值