@@ -88,6 +88,41 @@ $client = ClientBuilder::create() // Instantiate a new ClientBuilder
88
88
Only the `host` parameter is required for each configured host. If not provided, the default port is `9200`. The default
89
89
scheme is `http`.
90
90
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
+
91
126
=== Authorization and Encryption
92
127
93
128
For details about HTTP Authorization and SSL encryption, see
0 commit comments