Skip to content

Commit a462e46

Browse files
author
ivan.trnka
committed
docs
1 parent e3b15ae commit a462e46

File tree

1 file changed

+63
-2
lines changed

1 file changed

+63
-2
lines changed

README.md

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,63 @@
1-
# ha-elasticsearch-middleware
2-
Elasticsearch middleware for ha framework. Provides proxy to official elasticsearch API.
1+
# Elasticsearch for *ha* framework
2+
3+
Provides access to official [Elasticsearch PHP API](https://github.com/elastic/elasticsearch-php) as a middleware implementation for the framework.
4+
5+
## Installation
6+
7+
Installation is available via composer:
8+
9+
```bash
10+
composer require itrnka/ha-elasticsearch-middleware
11+
```
12+
13+
## Requirements
14+
15+
This package is based on [*ha* framework](https://github.com/itrnka/ha-framework). Composer installs *ha* framework automatically if it is not already installed.
16+
17+
## Configuration
18+
19+
Required configuration keys:
20+
21+
- `name`: by ha framework requirements
22+
- `hosts`: *string[]* list of elasticsearch hosts
23+
24+
Add your configuration to the configuration file in *ha* framework according to this example:
25+
26+
```php
27+
$cfg['middleware'] = [
28+
29+
// ...
30+
31+
// elasticsearch - single server
32+
[
33+
ha\Middleware\NoSQL\Elasticsearch\Elasticsearch::class,
34+
[
35+
'name' => 'ES001',
36+
'hosts' => ['127.0.0.1:9200'],
37+
]
38+
],
39+
40+
// elasticsearch - multi server
41+
[
42+
ha\Middleware\NoSQL\Elasticsearch\Elasticsearch::class,
43+
[
44+
'name' => 'ES002',
45+
'hosts' => ['10.10.10.1:9200', '10.10.10.2:9200'],
46+
]
47+
],
48+
49+
// ...
50+
];
51+
```
52+
53+
Then the elasticsearch will be available as follows:
54+
55+
```php
56+
// middleware instance
57+
$es1 = main()->middleware->ES001;
58+
$es2 = main()->middleware->ES002;
59+
60+
// es client (instance of \Elasticsearch\Client):
61+
$es1Client = main()->middleware->ES001->driver();
62+
$es2Client = main()->middleware->ES002->driver();
63+
```

0 commit comments

Comments
 (0)