0

A big beginner of Zend-framework on PHP calls, I could include it on Netbeans IDE. Now I'm trying to use it to achieve a Lucene indexer and searcher using Zend_Lucene, I followed the getting started of the official site, unfortunately they explain the whole thing with just few words. Anyway, I copied pasted this $index = Zend_Search_Lucene::create($indexPath);, but I got a message onto this line saying: Fatal error: Class 'Zend_Search_Lucene' not found in C:\wamp\www\witswork\luceneTry.php means that the function still unknown, maybe, some files need to be copied on my project folder but really I'm running out of ideas right now. Accept my regards, dany90.

Nadjib Mami
  • 5,736
  • 9
  • 37
  • 49

1 Answers1

0

You need to load the php file which contains the Zend_Search_Lucene class first. One option is to load your/path/to/library/Zend/Search/Lucene.php:

require_once 'my/path/to/library/Zend/Search/Lucene.php';
$index = new Zend_Search_Lucene::create($indexPath);

This class loads all its dependencies, so you don't need to worry about that.

Another option is to use the autoloader of Zend, Zend_Loader_Autoloader. This class is a singleton and registers itself with spl_autoload() when you retrieve it for the first time:

$autoloader = Zend_Loader_Autoloader::getInstance();
$index      = new Zend_Search_Lucene::create($indexPath);

After the autoloader is loaded, you just can use Zend_Search_Lucene without the require_once() call. In the manual of Zend Framework you can find more information about the autoloader.

Jurian Sluiman
  • 13,498
  • 3
  • 67
  • 99
  • Thanks Jurian, it worked without loader. these files have been created: read.lock.file, segments.gen, segments_1, write.lock.file but look what I got after the creating: equire_once(Zend/Search/Lucene/Storage/File/Filesystem.php) `[function.require-once]: failed to open stream: No such file or directory in C:\wamp\www\xxx\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349` – Nadjib Mami Jun 21 '11 at 19:55
  • Have you changed something in these files? The call should load the class `Zend_Search_Lucene_Storage_File_Filesystem`. This issue is caused by something else, because you can load the `Zend_Seach_Lucene` with require_once(). – Jurian Sluiman Jun 21 '11 at 20:03
  • Here is my code: `require_once "Zend/Search/Lucene.php"; $indexPath = "Documents"; $docUrl = "Documents"; $index = Zend_Search_Lucene::create($indexPath); $docTitle = "Plan"; $docBody = "planning"; $doc = new Zend_Search_Lucene_Document(); $doc->addField(Zend_Search_Lucene_Field::Text('url', $docUrl)); $doc->addField(Zend_Search_Lucene_Field::Text('title', $docTitle)); $doc->addField(Zend_Search_Lucene_Field::unStored('contents', $docBody));` – Nadjib Mami Jun 21 '11 at 20:11
  • @Dany90 probably you should update your `Zend` libraries to the latest version and see it that solves your problem. **Make sure the `Zend` directory & it's files has permission for `apache` to read**. – Rakesh Sankar Jun 23 '11 at 03:42
  • @Rakesh, I'm using the latest one, juts downloaded it since two days, but it was the `Minimal Package`, maybe I should use the `Full Package`, shouldn't I? then, from where I give permission to files in `apache`? – Nadjib Mami Jun 23 '11 at 09:32
  • You don't have to give permission, just download the `library` files and place it somewhere, make sure it's inside the `include_path` & give the "read/write" permission to others/apache for the above folder. – Rakesh Sankar Jun 23 '11 at 10:40
  • Where do I include files `inside include_path`? – Nadjib Mami Jun 23 '11 at 11:33
  • What can this error refer to: `Fatal error: require_once() [function.require]: Failed opening required 'Zend/Search/Lucene/Storage/File/Filesystem.php' (include_path='.;C:\php5\pear') in C:\wamp\www\witswork\Zend\Search\Lucene\Storage\Directory\Filesystem.php on line 349` please Rakesh really really need to make it works as soon as possible. – Nadjib Mami Jun 23 '11 at 11:36