Skip to content

Commit edbe7bd

Browse files
committed
connect to cloud doc
1 parent c7251bc commit edbe7bd

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/configuration.asciidoc

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,41 @@ $client = ClientBuilder::create() // Instantiate a new ClientBuilder
8888
Only the `host` parameter is required for each configured host. If not provided, the default port is `9200`. The default
8989
scheme is `http`.
9090

91+
=== Connect to Elastic Cloud
92+
93+
If you want to connect to Elastic Cloud, you can use your Cloud ID and use basic authentication or ApiKey authentication to connect to it.
94+
95+
[source,php]
96+
----
97+
use Elasticsearch\Helper\ElasticCloudHelper;
98+
99+
$cloud = new ElasticCloudHelper('elastic-cloud-id'); <1>
100+
$cloud->setBasicAuthentication('username', 'secure-password'); <2>
101+
102+
$client = ClientBuilder::create()
103+
->setHosts($cloud->getHost()) <3>
104+
->setElasticCloudConnectionParams() <4>
105+
->build();
106+
----
107+
<1> Your Cloud ID provided by the Elastic Cloud platform
108+
<2> Your basic authentication credentials
109+
<3> Let the `ElasticCloudHelper` unwrap the Cloud ID to a hostname
110+
<3> Activate the best practises for communicating with Elastic Cloud
111+
112+
[source,php]
113+
----
114+
use Elasticsearch\Helper\ElasticCloudHelper;
115+
116+
$cloud = new ElasticCloudHelper('elastic-cloud-id');
117+
118+
$client = ClientBuilder::create()
119+
->setHosts($cloud->getHost())
120+
->setElasticCloudConnectionParams()
121+
->setApiKeyPairAuthentication('id', 'api_key') <1>
122+
->build();
123+
----
124+
<1> Your ApiKey pair as described https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/security.html[here]
125+
91126
=== Authorization and Encryption
92127

93128
For details about HTTP Authorization and SSL encryption, see

0 commit comments

Comments
 (0)