gbprod / elastica-bundle
该包已废弃,不再维护。未建议替代包。
用于在Symfony应用中使用Elastica的简单捆绑包
v1.2.0
2018-02-05 15:39 UTC
Requires
- php: ^5.6|^7.0
- psr/log: ^1.0
- ruflin/elastica: ^3.2|^5.0|^6.0
- symfony/expression-language: ^2.7|^3.0|^4.0
- symfony/framework-bundle: ^2.7|^3.0|^4.0
- symfony/yaml: ^2.7|^3.0|^4.0
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.0
- symfony/browser-kit: ^2.7|^3.0|^4.0
- symfony/css-selector: ^2.7|^3.0|^4.0
- symfony/filesystem: ^2.7|^3.0|^4.0
- symfony/twig-bundle: ^2.7|^3.0|^4.0
- symfony/web-profiler-bundle: ^2.7|^3.0|^4.0
This package is auto-updated.
Last update: 2021-08-07 10:50:05 UTC
README
这是一个用于在Symfony应用中使用elastica的简单捆绑包。允许你在Symfony应用中创建elastica服务。目标是创建一个轻量级的FOSElasticaBundle替代品,因为有时我们不需要那么多东西。
安装
使用composer下载捆绑包
composer require gbprod/elastica-bundle
在app/AppKernel.php
文件中声明
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new GBProd\ElasticaBundle\ElasticaBundle(), // ... ); }
配置
客户端
# app/config/config.yml elastica: clients: default: host: 127.0.0.1 port: 9200 other_client: host: 127.0.0.1 port: 9201
如果使用集群
# app/config/config.yml elastica: clients: default: connections: - { host: localhost, port: 9200 } - { host: localhost, port: 9201 }
可用选项:host
、port
、path
、url
、proxy
、transport
、persistent
、timeout
和proxy
自定义日志记录器
默认情况下,此捆绑包使用Symfony的默认日志记录器(@logger
)在elastica
通道中记录查询。
您可以使用logger
配置选项使用自定义日志记录器。
# app/config/config.yml elastica: logger: my_custom_logger_service_id clients: default: host: 127.0.0.1 port: 9200
使用
现在您可以使用服务elastica.default_client
或elastica.my_other_client
$client = $container->get('elastica.default_client');
服务自动注入支持
Symfony 3.3引入了对服务自动注入的支持。要能够将Elastica连接自动注入到您的服务中,您需要将具有名称default
的客户端配置设置。如果您有多个连接,则只有default
连接将启用自动注入,因为服务自动注入是通过类名解析的。
默认情况下启用自动注入支持,但如果您出于某种原因需要禁用它,可以设置autowire: false
参数。
# app/config/config.yml elastica: autowire: false clients: default: host: 127.0.0.1 port: 9200
测试
克隆此存储库(或一个分支)。您应该安装php>=5.6
和composer
。
make test-unit
贡献
请随时贡献,有关更多信息,请参阅CONTRIBUTING.md文件。