【问题标题】:Zendframework(1.12.11) view helper not found in phpunitZendframework(1.12.11) 在 phpunit 中找不到视图助手
【发布时间】:2015-07-17 18:21:17
【问题描述】:

我的 zendframework 项目中有以下视图助手的目录结构

 --application
       --views
         --helpers
            --Test.php

application.ini 中的配置设置是

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

Bootstrap.php 中的配置是

$view->setHelperPath(APPLICATION_PATH . "/views/helpers/");

在Test.php文件中的命名约定是

class Zend_View_Helper_Test extends Zend_View_Helper_Abstract {}

并且我在需要的地方在模块中使用辅助函数。当我通过浏览器运行项目时,应用程序工作正常而没有任何错误,但是当我通过命令行为同一个应用程序调用 phpunit 时,我收到类似的错误

Fatal error: Uncaught exception 'ErrorException' with message 'include_once(Zend\View\Helper\Test.php): failed to open stream: No such file or directory' in D:\
zend\ZendServer\share\ZendFramework-1.12.11\library\Zend\Loader.php:134

这意味着它将在 zend 服务器库视图文件夹中找到 Test.php 文件。我不明白为什么它可以通过浏览器工作,而不能通过命令行在 phpunit 中工作。

【问题讨论】:

  • 你能分享一下你用来运行 PHPUnit 的命令和配置文件吗?您使用的是哪个版本的 PHPUnit?
  • 命令:phpunit -c phpunit.xml, phpunit 版本是3.7.21 ....

标签: zend-framework phpunit


【解决方案1】:

我得到了解决方案。我已经替换了 application.ini 的配置设置

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

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

并用

更改了 Test.php 的命名约定
class Application_View_Helper_Test extends Zend_View_Helper_Abstract {}

现在 zend loder 将尝试在应用程序目录而不是 Zend 中查找视图助手

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-04-22
    • 1970-01-01
    • 2020-08-15
    • 1970-01-01
    • 2014-09-23
    • 2011-11-23
    • 2011-03-14
    • 2018-08-23
    相关资源
    最近更新 更多