Xz Elasticsearch – A Silex Service Provider based on Elasticsearch-Php
dependencies:
A Silex Application
Append following properties to your composer json
"repositories": [
{
"type": "git",
"url": "https://github.com/xeroxzone/elasticsearch.git"
},
],
"require": {
"xeroxzone/elasticsearch": "dev-master"
},Clone from Github
Run Composer update for your project:
$ php composer.phar update xeroxzone/elasticsearchPHP Version >= 5.5.x
Usage example:
require_once __DIR__.'/../vendor/autoload.php';
use Silex\Application;
use Xz\Elasticsearch;
class MyApplication extends Application
{
use Elasticsearch\Traits\ElasticsearchTrait;
}
$application = new MyApplication();
$application->register(
new Elasticsearch\ElasticsearchServiceProvider(),
[
'elasticsearch.options' => [
'hosts' => [
'localhost:9200'
],
'connectionParams' => [
'auth' => [
'username',
'password',
'Basic'
]
]
]
]
);
$application->get('/', function() use ($application) {
$elasticsearch = $application->elasticsearch();
return $elasticsearch->ping();
});
$application->run();Further examples are found here ElasticsearchLibraryTest.php
Xz Elasticsearch is a product of 0xz.de is licensed under the MIT license.
Elasticsearch-Php is licensed under the Apache License.
Silex is licensed under the MIT license.