Zend_Layout +辅助类
我尝试在 Zend_Layout 选项中使用 helperClass 。 我创建一个类:
class Helper_Testi extends Zend_Controller_Action_Helper_Abstract{
public function init(){
echo "111111111";
$this->fff = 'hello from Helper';
}
public function getMessage(){
echo "==============";
return "message";
}
}
并在 Bootstrap.php 中尝试将其添加到 Zend_Layout:
$options = array('layout' => 'layout','helperClass'=>'../application/controllers/helper/Testi');
$layout = new Zend_Layout();
$layout->startMvc($options);
但是当我重新加载浏览器时,我看到异常:
Fatal error: Uncaught exception 'Zend_Exception' with message 'File "../application/controllers/helper/Testi.php" does not exist or class "../application/controllers/helper/Testi" was not found in the file'
我做错了什么?请帮助我。
I am try to use helperClass in Zend_Layout options.
I create a class:
class Helper_Testi extends Zend_Controller_Action_Helper_Abstract{
public function init(){
echo "111111111";
$this->fff = 'hello from Helper';
}
public function getMessage(){
echo "==============";
return "message";
}
}
and in Bootstrap.php try add it to Zend_Layout:
$options = array('layout' => 'layout','helperClass'=>'../application/controllers/helper/Testi');
$layout = new Zend_Layout();
$layout->startMvc($options);
But when I reload browser I see Exception:
Fatal error: Uncaught exception 'Zend_Exception' with message 'File "../application/controllers/helper/Testi.php" does not exist or class "../application/controllers/helper/Testi" was not found in the file'
What I do wrong? Help me please.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试在路径中使用 APPLICATION_PATH 常量
Try to use APPLICATION_PATH constant in your path
您需要将助手类放置在正确的位置。
例如,在我的引导程序中,有这样的行:
辅助文件将位于此文件夹中:
Icc\View\Helper\
编辑:
例如,我有文件
FormDropdown.php
具有这样的内容:
鉴于我可以通过这种方式使用这个助手:
You need place your helper class in correct place.
E.g. in my bootsrap there are such lines:
And helper files will be located in this folder:
Icc\View\Helper\
Edit:
E.g. I have file
FormDropdown.php
with such content:
In view I can use this helper in this way: