Skip to content

Commit c29bf25

Browse files
authored
Merge pull request #1107 from szabosteve/7.x.drs.config
[7.x][DOCS] Adds Configuration section to PHP docs
2 parents 30e6af9 + 6b18fc8 commit c29bf25

20 files changed

+532
-541
lines changed

docs/community.asciidoc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ and elasticsearch-php client. You can easily build any {es} query and transform
1212
it to an array.
1313
__________________________
1414

15-
1615
[discrete]
1716
=== elasticsearcher
1817

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

29-
3028
[discrete]
3129
=== ElasticSearchQueryDSL
3230

@@ -87,6 +85,7 @@ include:
8785
- Listeners for Doctrine events for automatic indexing.
8886
__________________________
8987

88+
9089
[discrete]
9190
=== Drupal
9291

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

116+
117117
[discrete]
118118
==== cviebrock/Laravel-Elasticsearch
119119

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

127+
127128
[discrete]
128129
==== Plastic
129130

docs/config-hash.asciidoc

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[discrete]
2+
[[config-hash]]
3+
=== Building the client from a configuration hash
4+
5+
To help ease automated building of the client, all configurations can be
6+
provided in a setting hash instead of calling the individual methods directly.
7+
This functionality is exposed through the `ClientBuilder::FromConfig()` static
8+
method, which accepts an array of configurations and returns a fully built
9+
client.
10+
11+
Array keys correspond to the method name, for example `retries` key corresponds
12+
to `setRetries()` method.
13+
14+
[source,php]
15+
----
16+
$params = [
17+
'hosts' => [
18+
'localhost:9200'
19+
],
20+
'retries' => 2,
21+
'handler' => ClientBuilder::singleHandler()
22+
];
23+
$client = ClientBuilder::fromConfig($params);
24+
----
25+
26+
27+
Unknown parameters throw an exception, to help the user find potential problems.
28+
If this behavior is not desired (for example, you are using the hash for other
29+
purposes, and may have keys unrelated to the {es} client), you can set
30+
$quiet = true in fromConfig() to silence the exceptions.
31+
32+
[source,php]
33+
----
34+
$params = [
35+
'hosts' => [
36+
'localhost:9200'
37+
],
38+
'retries' => 2,
39+
'imNotReal' => 5
40+
];
41+
42+
// Set $quiet to true to ignore the unknown `imNotReal` key
43+
$client = ClientBuilder::fromConfig($params, true);
44+
----

0 commit comments

Comments
 (0)