XAMPP + Zend Framework = .phtml 文件不渲染
我安装了 XAMPP 和一个基于 Zend Framework 构建的应用程序,可以在正常的 apache2 + php5 环境中工作。该应用程序驻留在正确配置的虚拟主机内,作为预防措施,我还添加了 .phtml 文件以匹配 php 编译器
<FilesMatch "\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$">
SetHandler application/x-httpd-php
</FilesMatch>
。当我访问应用程序的任何页面时,我会得到在浏览器中呈现的 php 代码,而不是呈现的 html。 PHP 文件被编译,因此在渲染之前任何地方的 die('aaa') 都会按预期工作。但是,当 Zend_View 在方法 _run() 中包含脚本文件时,所有内容都会以文本形式输出到浏览器。
我在测试目录中使用普通的index.phtml 文件进行了测试,它的行为就像一个php 文件。它由 php.exe 解释,但是当 zend 包含视图脚本时我无法弄清楚发生了什么。
有人可以提供一些帮助吗?
I have an installation of XAMPP and an application built on Zend Framework that works in a normal apache2 + php5 environment. The application resides inside a vhost correctly configured and as a precaution I also added .phtml files to match php compiler
<FilesMatch "\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$">
SetHandler application/x-httpd-php
</FilesMatch>
When I access any page of the application I get the php code rendered in browser instead of the rendered html. PHP files are compiled, so a die('aaa') in any place before rendering works as expected. But when Zend_View includes the script file in method _run() everything gets outputed to browser as text.
I tested with a plain index.phtml file in a test directory and it acts like a php file. it is interpreted by php.exe, but when zend includes view scripts I can't figure out what's happening.
Can someone offer some help ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
3个小时后我发现了问题所在。我不敢相信我花了这么长时间,但问题是配置不允许 php_short_tag,这在处理模板时是一个很棒的功能。
我已经在 php.ini 中启用了短标签并重新启动了 apache:
我已经在这里发布了答案,因为有一天有人可能会遇到我的问题。
I found where the problem is, after 3 hours.. I can't believe it took me that long, but the issue was configuration did not allow php_short_tag, which is a great feature when dealing with templates.
I have enabled short tag in php.ini and restarted apache:
I've posted the answer here because someone might have my problem some day.
我认为您不必在虚拟主机内创建该指令。默认的 xampp 安装将为 php 注册 phtml 文件。默认情况下,XAMPP 将具有以下扩展名的文件传递给 PHP: .php .php5 .php4 .php3 .phtml .phpt
检查此配置文件 c:/xampp/apache/conf/extra/httpd-xammp
我有以下行
I don't think you have to create that directive inside the vhost. A default xampp install will register phtml files for php. XAMPP passes by default files with the following extensions to PHP: .php .php5 .php4 .php3 .phtml .phpt
check this config file c:/xampp/apache/conf/extra/httpd-xammp
I have this lines