1[discrete] 2[[config-hash]] 3=== Building the client from a configuration hash 4 5To help ease automated building of the client, all configurations can be 6provided in a setting hash instead of calling the individual methods directly. 7This functionality is exposed through the `ClientBuilder::FromConfig()` static 8method, which accepts an array of configurations and returns a fully built 9client. 10 11Array keys correspond to the method name, for example `retries` key corresponds 12to `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 27Unknown parameters throw an exception, to help the user find potential problems. 28If this behavior is not desired (for example, you are using the hash for other 29purposes, 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----