首先确保您已安装以下内容:
- curl(确保你已将 curl 添加到路径环境中
变量)
- 作曲家
确保在命令行使用的 php.ini 中启用了 openssl。 (对于那些在 windows 上使用 wamp 的人,有两个 php ini 文件。一个用于 apache,另一个用于命令行。)
启动命令行并使用CD命令进入你解压的目录zend搜索并运行以下两个命令
curl -s h**ps://getcomposer.org/installer | php
php composer.phar 安装
在同一目录下创建一个php文件并包含.vendor/autoload.php
创建一个创建自动加载函数来加载不同的库。目前我写了一些简单的东西如下:
函数 autoload($classname)
{
$path = __DIR 。 DS 。 “图书馆” .DS 。 $类名。 ".php";
if(file_exists($path))
{
需要一次($路径);
}
}
这应该加载不同的类,前提是您知道它们的命名空间。这是基本的自动加载器,不应使用。
我一直在使用以下guide,但是它已经过时了,因为类的名称已被修改为如下所示:
$indexPath = 'C:\wamp\www\storage'; $索引 =
ZendSearch\Lucene\Lucene::create($indexPath);
$doc = new ZendSearch\Lucene\Document();
$doc->addField(ZendSearch\Lucene\Document\Field::UnIndexed('url',
$docUrl));
$doc->addField(ZendSearch\Lucene\Document\Field::UnIndexed('created',
$docCreated));
$doc->addField(ZendSearch\Lucene\Document\Field::UnIndexed('teaser',
$docTeaser));
$doc->addField(ZendSearch\Lucene\Document\Field::Text('title',
$文档标题));
$doc->addField(ZendSearch\Lucene\Document\Field::Text('author',
$doc作者));
$doc->addField(ZendSearch\Lucene\Document\Field::UnStored('contents',
$docBody));
$index->addDocument($doc); $index->commit();