Zendframework(1.12.11) 在 phpunit 中找不到视图助手
Zendframework(1.12.11) view helper not found in phpunit
我的 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 {}
并且我在任何需要的地方都在模块中使用辅助函数 it.When 我 运行 通过浏览器进行项目,应用程序工作正常没有任何错误,但是当我通过命令行为同一个应用程序调用 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 文件 folder.I 我不明白为什么它通过浏览器工作而不通过命令行在 phpunit 中工作。
我找到了解决方案。我已经替换了 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 中查找视图助手
我的 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 {}
并且我在任何需要的地方都在模块中使用辅助函数 it.When 我 运行 通过浏览器进行项目,应用程序工作正常没有任何错误,但是当我通过命令行为同一个应用程序调用 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 文件 folder.I 我不明白为什么它通过浏览器工作而不通过命令行在 phpunit 中工作。
我找到了解决方案。我已经替换了 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 中查找视图助手