2

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.

DadaB
  • 762
  • 4
  • 12
  • 29
  • Is your `/usr/local/Zend` the direct library? like when you open it, you have all the framework? – Frederick Marcoux Mar 22 '13 at 04:26
  • Sadly I cant access zend directory to see its content, as it is Hostgator shared hosting account. Maybe any advices on how could I upload and use my own zend framework... Like can I upload it to lets say /home/username/public_html/website/Zend or /home/username/public_html/Zend directory, and then use it without any problems? – DadaB Mar 22 '13 at 07:47
  • This error is just telling you that you need to implement the autoloader for Zend Framework. If your web host is hosting Zend Framework they likely have a code snippet that needs to be used to have the correct paths and permissions. Check out http://stackoverflow.com/questions/1466252/zend-framework-1-9-how-to-use-autoloading-without-mvc – RockyFord Mar 22 '13 at 09:43

2 Answers2

1

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.

SeanWM
  • 16,789
  • 7
  • 51
  • 83
  • Hmm could the problem be, that my host uses Zend framework 2 (wich as it seems doesnt include lucene module as default anymore).. So the question is how could I upload and use lucene module on shared host, as I found I can download it from https://github.com/zendframework/ZendSearch . Thanks P.S. Im editing code right now to see if your sggestion works, but I believe I will have lucene module problem too – DadaB Mar 25 '13 at 15:22
  • P.P.S. Your suggestion didnt helped :( Im still getting loader.php error too (... Failed opening required 'Loader.php' (include_path='.:/usr/lib/php:/usr/local/lib/php:/usr/local/Zend') ...) . Is there any simple way i could just upload zend framework files to my host and use them? – DadaB Mar 25 '13 at 15:28
  • Hmm ok. have you looked at the [setup documentation](http://framework.zend.com/manual/1.12/en/introduction.installation.html)? – SeanWM Mar 25 '13 at 15:30
  • THanks, I found solution anyway. P.S. At least to me, Zend documentation is pain in the ass :D Some parts are very confusing especially for unexperiened dev's like me :) – DadaB Mar 30 '13 at 20:50
0

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;
DadaB
  • 762
  • 4
  • 12
  • 29