wikibusiness / elastica-bundle
Elastica的精简封装包,当FOSElasticaBundle过于复杂时使用。
1.2
2015-04-10 21:19 UTC
Requires
- php: >=5.5
- ruflin/elastica: ~1.3
This package is not auto-updated.
Last update: 2024-09-14 16:37:26 UTC
README
这是一个简单的Symfony封装elastica的包。它允许你将elastica配置为Symfony中的服务。
安装
通过composer
进行安装
$ composer require wikibusiness/elastica-bundle
将包添加到您的内核中
// app/AppKernel.php class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new WB\ElasticaBundle\WBElasticaBundle(), ); // ... } } // ...
配置包
# app/config/config.yml wb_elastica: servers: main: host: 127.0.0.1 port: 9200
其中main
是一个分组。
如果你想在集群模式下使用Elastica,配置部分应类似于以下这样
# app/config/config.yml wb_elastica: servers: host_1: host: 127.0.0.1 port: 9200 host_2: host: 127.0.0.1 port: 9201
全部完成,你现在可以通过服务wb_elastica.client
访问服务,如下所示
use Elastica\Search; $client = $container->get('wb_elastica.client'); $search = new Search($client); ...