Skip to content

Commit

Permalink
[DOCS] Adds Configuration section to PHP docs. (elastic#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
szabosteve committed Feb 16, 2021
1 parent 30e6af9 commit 6b18fc8
Show file tree
Hide file tree
Showing 20 changed files with 532 additions and 541 deletions.
5 changes: 3 additions & 2 deletions docs/community.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ and elasticsearch-php client. You can easily build any {es} query and transform
it to an array.
__________________________


[discrete]
=== elasticsearcher

Expand All @@ -26,7 +25,6 @@ application. It does not want to hide or replace functionality of the {es} PHP
client.
__________________________


[discrete]
=== ElasticSearchQueryDSL

Expand Down Expand Up @@ -87,6 +85,7 @@ include:
- Listeners for Doctrine events for automatic indexing.
__________________________


[discrete]
=== Drupal

Expand Down Expand Up @@ -114,6 +113,7 @@ __________________________
This is a Laravel (4+) Service Provider for the official {es} low-level client.
__________________________


[discrete]
==== cviebrock/Laravel-Elasticsearch

Expand All @@ -124,6 +124,7 @@ __________________________
An easy way to use the official {es} client in your Laravel applications.
__________________________


[discrete]
==== Plastic

Expand Down
44 changes: 44 additions & 0 deletions docs/config-hash.asciidoc
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);
----
Loading

0 comments on commit 6b18fc8

Please sign in to comment.