Skip to content

Commit c78a187

Browse files
committed
Update README
1 parent 7b6e247 commit c78a187

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,36 @@ return [
6262
];
6363
```
6464

65+
If you need more control over the client creation, you can create your own client builder:
66+
67+
```php
68+
// see Elastic\Client\ClientBuilder for the reference
69+
class MyClientBuilder implements Elastic\Client\ClientBuilderInterface
70+
{
71+
public function default(): Client
72+
{
73+
// should return a client instance for the default connection
74+
}
75+
76+
public function connection(string $name): Client
77+
{
78+
// should return a client instance for the connection with the given name
79+
}
80+
}
81+
```
82+
83+
Do not forget to register the builder in your application provider:
84+
85+
```php
86+
class MyAppProvider extends Illuminate\Support\ServiceProvider
87+
{
88+
public function register()
89+
{
90+
$this->app->singleton(ClientBuilderInterface::class, MyClientBuilder::class);
91+
}
92+
}
93+
```
94+
6595
## Usage
6696

6797
Use `Elastic\Client\ClientBuilderInterface` to get access to the client instance:

0 commit comments

Comments
 (0)