PHP Zend Framework:尝试运行“Lucene.php”时,本地主机上出现内部服务器错误 500在浏览器上
我运行的是 Windows 7,并且全新安装了 Zend 框架。在一个名为“search.php”的新 php 文件中,我尝试使用 Zend_Search_Lucene 构建一个搜索应用程序,第一行是:
<?php require_once "C:...\Zend\Search\Lucene.php";?>
当我运行此代码时,我在浏览器上看到的是内部服务器错误 500..然后我发现我每当我尝试单独运行 Zend 库中的某些文件时,都会出现此错误,这就是导致我提到的错误的原因。即 localhost/Zend/Search/Lucene.php、localhost/Zend.../blabla 上的 ERROR 500 .php ..
但是,某些文件在浏览器上运行时并未显示此 500 服务器错误。即: localhost/Zend/ProgressBar.php 显示一个空页面,这很好,因为我假设代码中没有任何“回显”。这实际上是我在浏览器上运行 lucene.php 时所期望的......
有经验的人可以让我知道这是如何发生的吗?为什么我收到内部服务器错误而不是异常?无论出现此内部 500 服务器错误,如何检查使用“Lucene.php”文件的搜索应用程序是否正常运行?谢谢。
I am running windows 7 and I have a fresh install of Zend framework. On a new php file called 'search.php' I am trying to build a search application using Zend_Search_Lucene with the first line being:
<?php require_once "C:...\Zend\Search\Lucene.php";?>
What I see on the browser when I run this code is internal server error 500..I then discovered that I get this error whenever I try to run some of the files in Zend library by itself and this is what caused the error I mentioned..i.e ERROR 500 on localhost/Zend/Search/Lucene.php, localhost/Zend.../blabla.php..
Some of the files however, did not display this 500 server error when run on the browser. ie: localhost/Zend/ProgressBar.php shows an empty page, which is fine since I assume there are not any 'echo'es in the code. This is actually what I expected when I ran lucene.php on the browser...
Can somebody experienced let me know how this can happen? Why do I get internal server error instead of exception? How do I check if my search application that uses "Lucene.php" file runs properly regardless of this internal 500 server error? thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试打开错误报告:
即时
在 php.ini(对于 php 和 cli 可能不同)
有关详细信息,请参阅:
Try to turn on error reporting:
on the fly
in php.ini (probably different for php and cli)
For more information see:
我终于解决了这个问题:)查看错误痕迹后,内部服务器错误是因为代码
尝试访问“Lucene.php”中的特定代码,其中包含 Zend 库文件夹的相对路径 =
require_once('Zend\Search\Document\...');
和服务器不知道文件的路径。需要修复的实际上是我的 php.ini 文件,在 include_path 上我添加了;C:\php5\pear;C:\Server\www\.....\ZendFramework\library
。 。现在它显示空页面而不是内部服务器错误。+1 @Arend:错误报告功能真的很有用!谢谢
I have finally solved the problem :) After looking at the error traces, the internal server error is because the code
<?php require_once "C:...\Zend\Search\Lucene.php";?>
tries to access a particular code inside "Lucene.php" that contains a relative path to the Zend library folder =require_once('Zend\Search\Document\...');
and the server does not know the path to the file. What needed to be fixed was actually my php.ini file, on the include_path i added;C:\php5\pear;C:\Server\www\.....\ZendFramework\library
..Now it shows empty page instead of internal server error.+1 @Arend: The error reporting function is really useful! thanks
Zend 的代码依赖于他们的自动加载器。你会得到一个错误,因为你没有初始化它,然后在 Zend_Search_Lucene 中它尝试实例化一个不存在的类。
这应该可以解决问题:
Zend's code relies on their autoloader. You get an error, since you don't initialize it, then in Zend_Search_Lucene it tries to instanciate a nonexistent class.
This should do the trick:
由于我无法评论答案,因此我重新使用 Maerlyn 的代码:
self::$zendLoaded = true;
无法工作,因为self
未定义她。根据 ZF 文档,如果您的路径设置正确,这两行应该足够了。
As I cannot comment answers, I re-use Maerlyn's code :
self::$zendLoaded = true;
cannot work asself
is not defined her.According to the ZF documentation, if your path is set correctly, these 2 lines should be enough.