forked from elastic/elasticsearch-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOCS] Adds Configuration section to PHP docs. (elastic#1100)
- Loading branch information
1 parent
30e6af9
commit 6b18fc8
Showing
20 changed files
with
532 additions
and
541 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[discrete] | ||
[[config-hash]] | ||
=== Building the client from a configuration hash | ||
|
||
To help ease automated building of the client, all configurations can be | ||
provided in a setting hash instead of calling the individual methods directly. | ||
This functionality is exposed through the `ClientBuilder::FromConfig()` static | ||
method, which accepts an array of configurations and returns a fully built | ||
client. | ||
|
||
Array keys correspond to the method name, for example `retries` key corresponds | ||
to `setRetries()` method. | ||
|
||
[source,php] | ||
---- | ||
$params = [ | ||
'hosts' => [ | ||
'localhost:9200' | ||
], | ||
'retries' => 2, | ||
'handler' => ClientBuilder::singleHandler() | ||
]; | ||
$client = ClientBuilder::fromConfig($params); | ||
---- | ||
|
||
|
||
Unknown parameters throw an exception, to help the user find potential problems. | ||
If this behavior is not desired (for example, you are using the hash for other | ||
purposes, and may have keys unrelated to the {es} client), you can set | ||
$quiet = true in fromConfig() to silence the exceptions. | ||
|
||
[source,php] | ||
---- | ||
$params = [ | ||
'hosts' => [ | ||
'localhost:9200' | ||
], | ||
'retries' => 2, | ||
'imNotReal' => 5 | ||
]; | ||
// Set $quiet to true to ignore the unknown `imNotReal` key | ||
$client = ClientBuilder::fromConfig($params, true); | ||
---- |
Oops, something went wrong.