Skip to content

[7.x][DOCS] Adds Configuration section to PHP docs #1107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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