开发者

PHP Zend Framework: Internal Server Error 500 on localhost when trying to run "Lucene.php" on browser

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 discover开发者_开发技巧ed 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.


Try to turn on error reporting:

on the fly

ini_set('display_errors', 1);
error_reporting(E_ALL);

in php.ini (probably different for php and cli)

error_reporting = E_ALL
display_errors = 1

For more information see:

  • http://php.net/manual/en/errorfunc.configuration.php
  • http://php.net/manual/en/function.error-reporting.php


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'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:

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
self::$zendLoaded = true;


As I cannot comment answers, I re-use Maerlyn's code :

require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();

self::$zendLoaded = true; cannot work as self is not defined her.

According to the ZF documentation, if your path is set correctly, these 2 lines should be enough.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜