benjybe/silexprovider-service_elasticsearch

dev-master 2015-03-18 18:05 UTC

README

Another PHP Silex ElasticSearch Wrapper for Silex.
This provider uses the PHP Elastica Library.

For more informations about Silex, please visit the SensioLabs Silex Website.
For more informations about Elastica, please visit the Elastica IO Website.

Build Status SensioLabsInsight

Installation

Add the line below into your composer.json.

{
    "require": {
        "benjybe/silexprovider-service_elasticsearch": "*"
    }
}

Run the composer install (update)command to retrieve dependencies and update the autoloader.

Silex Registration

To register the ES service provider within your application, please follow the instructions below :

From a YAML configuration file(with Wise or other) :

service_elasticsearch:
  class: VPG\Silex\Provider\ElasticSearchServiceProvider
  parameters:
    elasticsearch:
     connections:
        default:
          host: 'localhost'
          port: 9200

Directly into your bootstrap PHP file :

use VPG\Silex\Provider\ElasticSearchServiceProvider;
// ...
$application->register(new ElasticSearchServiceProvider(), array(
    'elasticsearch' => array(
        'connections' => array(
            'default' => array(
                'host' => 'localhost',
                'port' => 9200
            ),
            'cluster' => array(
                'server' => array(
                    array('host' => 'localhost', 'port' => 9200),
                    array('host' => 'localhost', 'port' => 9205),
                )
            )
        )
    )
));

Usage

You can access the ES manager by two ways listed below :

$dm = $app['es.default_manager'];
$dm = $app['es.manager']('default');

(PROVIDER IN PROGRESS)