Question

I've searched for many info on the internet, also tried many various suggestions, but nothing seems to work as I need. So here is the problem: I want to use Zend_Search_Lucene to perform search in database, but I've stuck at the very begining.. creating Index and getting Zend to work at all. Im on shared Hostgator host and using this php code to generate my index:

include ('/home/username/public_html/website/config.php');

$path = '/usr/local/Zend';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('Zend/Loader.php');
Zend_Loader::registerAutoload();
require_once ('Zend/Search/Lucene.php');
$index = Zend_Search_Lucene::create('/home/username/public_html/website/tmpbuild');
    $con = mysql_connect("".$dbhost."","".$dbusername."","".$dbpass."");
    if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }

        mysql_select_db("".$dbname."", $con);

$sql = ('SELECT * FROM rasti_failai');
while($eilute = mysql_fetch_array($sql))
        {
        $filenamesql = $eilute['failu_name'];
        $dydissql = $eilute['dydis'];
        $hostas = $eilute['hostas'];
        $datasql = $eilute['data'];
        $aprasymassql = $eilute['header'];
        $titlesql = $eilute['aprasymas'];
        $url = $eilute['url'];
        $links = $eilute['links'];      

    $document = new Zend_Search_Lucene_Document ();

$document->addField(Zend_Search_Lucene_Field::unIndexed('ID', $eilute['ID']));
$document->addField(Zend_Search_Lucene_Field::Text('failu_name', $eilute['failu_name']));
$document->addField(Zend_Search_Lucene_Field::UnStored('dydis', $eilute['dydis']));
$document->addField(Zend_Search_Lucene_Field::UnStored('hostas', $eilute['hostas']));
$document->addField(Zend_Search_Lucene_Field::UnStored('header', $eilute['header']));
$document->addField(Zend_Search_Lucene_Field::UnStored('aprasymas', $eilute['aprasymas']));
$document->addField(Zend_Search_Lucene_Field::UnStored('url', $eilute['url']));
    $index->addDocument($document);     }
$index->commit();
echo $index->count() . " documents have been indexed.\n";

But it seems I can't get Zend framework to work, as Im getting this error:

Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No such file or directory in /home/username/public_html/website/adminp/lucene.php on line 15

Fatal error: require_once() [function.require]: Failed opening required 'Zend/Loader.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/Zend') in /home/username/public_html/website/adminp/lucene.php on line 15

My host has zend framework (tho I dont know exact version, but I think hostgator uses latest one, and Im using php5) installed, and support says its in /usr/local/Zend directory.

Was it helpful?

Solution 2

Ok, I've fixed it. If anyone need info how I did it here is detaild explanation: First of all, I've downloader zend framework 1 (as 2nd version doesnt has Lucene module by default) Then use this step by step:

  1. Upload Zend framework into your hosting server (path : root/library/Zend)

  2. Look for your DOCUMENT_ROOT path

    echo phpinfo();

3.Create or update your php5.ini or php.ini file wich is located in rood dir of your hosting account. (If you are using php5, you need to use php5.ini file)

put this line, (If you already have, add this line end of the current set, connected with ‘:’)

include_path = [DOCUMENT_ROOT]/Zend Path

ex) include_path = /home/content/m/i/s/misskoreabbq/html/library

Now for testing whether the zend installed well or not, let’s print out the zend frame work version.

require_once 'Zend/Version.php';
echo 'Your Zend Framework version = ' . Zend_Version::VERSION;

OTHER TIPS

You're already setting the include path with set_include_path(); so you're in the Zend/ directory as you've shown here:

$path = '/usr/local/Zend';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('Zend/Loader.php');

I believe changing your last line to this should work:

require_once('Loader.php');

The error simply means it can't find the file you're specifying.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top