Skip to content

Commit 4debf35

Browse files
author
ivan.trnka
committed
+ client() method
1 parent 3d15a9c commit 4debf35

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Elasticsearch for *ha* framework
22

3-
Provides access to official [Elasticsearch PHP API](https://github.com/elastic/elasticsearch-php) as a middleware implementation for *ha* framework.
3+
Provides access to official [Elasticsearch PHP API](https://github.com/elastic/elasticsearch-php) as a middleware implementation for *ha* framework. Automatically creates a client based on the configuration when it starts the application.
44

55
## Installation
66

@@ -12,7 +12,7 @@ composer require itrnka/ha-elasticsearch-middleware
1212

1313
## Requirements
1414

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.
15+
This package is based on [*ha* framework](https://github.com/itrnka/ha-framework). Composer installs *ha* framework and Elasticsearch PHP API automatically if it is not already installed.
1616

1717
## Configuration
1818

@@ -60,4 +60,8 @@ $es2 = main()->middleware->ES002;
6060
// es client (instance of \Elasticsearch\Client):
6161
$es1Client = main()->middleware->ES001->driver();
6262
$es2Client = main()->middleware->ES002->driver();
63+
64+
// or (this is the same)
65+
$es1Client = main()->middleware->ES001->client();
66+
$es2Client = main()->middleware->ES002->client();
6367
```

src/Elasticsearch/Elasticsearch.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,16 @@ final public function driver() : Client
6565
{
6666
return $this->driver;
6767
}
68+
69+
70+
/**
71+
* Get client instance.
72+
*
73+
* @return Client
74+
*/
75+
final public function client() : Client
76+
{
77+
return $this->driver;
78+
}
6879

6980
}

0 commit comments

Comments
 (0)