wikibusiness/elastica-bundle

Elastica的精简封装包,当FOSElasticaBundle过于复杂时使用。

安装次数: 1,171

依赖者: 0

推荐者: 0

安全性: 0

星标: 0

关注者: 4

分支: 0

开放问题: 0

类型:symfony-bundle

1.2 2015-04-10 21:19 UTC

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);
...