# Content

This extension integrates the ruflin/elastica (opens new window) into Nette Framework. For more information on how to use Elastica read the official documentation (opens new window).

# Setup

composer require contributte/elastica
1

register extension

extensions:
	elastica: Contributte\Elastica\DI\ElasticaExtension
1
2

# Configuration

Define at least one host, this would be minimal possible config.

elastica:
	config:
		host: localhost
1
2
3

Full config with all possible options.

elastica:
	debug: %debugMode%
	config:
		host: null
		port: null
		path: null
		url: null
		proxy: null
		transport: null
		compression: false
		persistent: true
		timeout: null
		connections: []
		roundRobin: null
		retryOnConflict: 0
		bigintConversion: null
		username: null
		password: null
		auth_type: null
		curl: []
		headers: []
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

Extension does not pass any unset values to elastica so elastica defaults just work. Take a look to Elastica docs (opens new window).

In docker environment you should use host: elasticsearch and port: 9200 for example.

# Usage

Extension registers Contributte\Elastica\Client to DI container.

class YourService
{
	/** @var \Contributte\Elastica\Client */
	private $elasticaClient;

	public function __construct(Contributte\Elastica\Client $elastica)
	{
		$this->elasticaClient = $elastica;
	}
}
1
2
3
4
5
6
7
8
9
10

# Monolog

You can use monolog to log errors to kibana.

Just register ElasticaHandler in monolog setup.

  • Monolog\Handler\ElasticaHandler

# Inspiration

Inspired by Filip Procházka (opens new window) package kdyby/ElasticSearch (opens new window).