gbprod / elastica-bundle
Really simple bundle to use Elastica within Symfony applications
Installs: 19 283
Dependents: 0
Suggesters: 1
Security: 0
Stars: 4
Watchers: 2
Forks: 0
Open Issues: 1
Type:bundle
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
Really simple bundle to use elastica within Symfony applications. Allows you to create elastica service in Symfony application. The aim is to create a ligthweigth alternative to FOSElasticaBundle, because sometimes, we don't need all that stuffs.
Installation
Download bundle using composer :
composer require gbprod/elastica-bundle
Declare in your app/AppKernel.php
file:
<?php // app/AppKernel.php public function registerBundles() { $bundles = array( // ... new GBProd\ElasticaBundle\ElasticaBundle(), // ... ); }
Configuration
Clients
# app/config/config.yml elastica: clients: default: host: 127.0.0.1 port: 9200 other_client: host: 127.0.0.1 port: 9201
If using a cluster:
# app/config/config.yml elastica: clients: default: connections: - { host: localhost, port: 9200 } - { host: localhost, port: 9201 }
Available options: host
, port
, path
, url
, proxy
, transport
, persistent
, timeout
and proxy
Custom logger
By default, this bundle logs queries using the Symfony's default logger (@logger
) into an elastica
channel.
You can use a customized logger with the logger
configuration option:
# app/config/config.yml elastica: logger: my_custom_logger_service_id clients: default: host: 127.0.0.1 port: 9200
Usage
You can now use service elastica.default_client
or elastica.my_other_client
$client = $container->get('elastica.default_client');
Services autowiring support
Symfony 3.3 have introduced support for services autowiring. To be able to autowire Elastica connection into your services you need to setup your client configuration with a name default
. In a case if you have multiple connections - only default
connection will be enabled for autowiring because services autowiring is resolved by class names.
Autowiring support is enabled by default, but if you need to disable it for some reason - you can do it by set autowire: false
parameter:
# app/config/config.yml elastica: autowire: false clients: default: host: 127.0.0.1 port: 9200
Tests
Clone this repository (or a fork). You should have php>=5.6
and composer
installed.
make test-unit
Contributing
Feel free to contribute, see CONTRIBUTING.md file for more informations.