docs/reference/index.md
The {{es}} PHP client is designed to be a low-level client. All methods closely match the REST API and the method structure of other language clients. This makes it easier to get started with a client and switch from one language to another.
It provides a response-handling layer that makes it easier to access HTTP responses in different formats. The PSR-18 HTTP response can be accessed as a PHP array, object, or a raw string. For more details, refer to blog post for {{es}} PHP client. Additionally, the client provides helpers to map an ES|QL result directly to a PHP object. For more information, refer to map php result to an object.
The client allows you to make API calls and read the response in multiple formats: associative array, object, raw string, or PSR-7 response.
For a step-by-step quickstart with the client, refer to the Getting started guide .
The {{es}} PHP client uses the PSR 7 standard. This standard is a community effort that contains a set of interfaces defined by the PHP Framework Interop Group. For more information, refer to the PSR 7 standard documentation.
The {{es}} PHP client is compatible with PHP versions that are currently maintained and supported.
{{es}} language clients are forward compatible. This ensures that the client remains compatible with {{es}} instances running the same or newer minor versions, preventing any breaking changes. However, for all new features in the newer {{es}} versions, the client will support them only after a new client version is released. For example, the 8.12 {{es}} PHP client does not support new features in
{{es}} 8.13. You must upgrade to the 8.13 version of the {{es}} PHP client to use them.
{{es}} language clients are backward-compatible only with default distributions and there are no guarantees for customized or modified versions. The following table provides the compatibility information between {{es}} and {{es}} PHP client:
| Elasticsearch Version | Elasticsearch-PHP Branch | Supported |
|---|---|---|
| main | main | |
| 9.x | 9.x | 9.x |
| 8.x | 8.x | 8.x |
The elasticsearch-php client version 9.x follows the same architecture as 8.x. It continues to support PSR-7 for HTTP messages and PSR-18 for HTTP client communications.
Although we've worked to keep 9.x backward compatible, the following important changes may impact your setup:
9.x: All changes and additions to {{es}} APIs 9.x release are reflected in the elasticsearch-php client release. You must use elasticsearch-php client version 9.x to access all new endpoints in {{es}} 9.x. Using an older client version will break your code.elastic/elasticsearch-serverless is deprecated, and all its functionality has been merged into the elasticsearch-php client. This doesn't have any impact on the default working of the client.@group serverless phpdoc attribute.410 HTTP error with the message: This endpoint exists but is not available when running in serverless mode.*.elastic.cloud, the 9.x client will recognize that it is communicating with a serverless instance.9.x client will recognize that the host is serverless from the first response. Alternatively, you can explicitly specify that the host is serverless using the Client::setServerless(true) function. The argument to this function is set to false by default.Guzzle dependency from the client. The built-in cURL-based HTTP client will be used by default if no other PSR-18 compatible clients are detected. See release 9.0.0 of elastic-transport-php.For detailed information on all the breaking changes, refer to breaking changes.