breaking-changes.asciidoc 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. [[breaking_changes]]
  2. === Breaking changes from 7.x
  3. This major release is a complete new PHP client for {es}. We build it from scratch!
  4. We tried to reduce the BC breaks as much as possible but there are some (big) differences:
  5. [discrete]
  6. ==== Architectural changes
  7. - we changed the namespace, now everything is under `Elastic\Elasticsearch`
  8. - we used the https://github.com/elastic/elastic-transport-php[elastic-transport-php] library for HTTP communications;
  9. - we changed the `Exception` model, using the namespace `Elastic\Elasticsearch\Exception`. All the exceptions extends the
  10. `ElasticsearchException` interface, as in 7.x
  11. - we changed the response type of each endpoint using an https://github.com/elastic/elasticsearch-php/blob/master/src/Response/Elasticsearch.php[Elasticsearch] response class.
  12. This class wraps a https://www.php-fig.org/psr/psr-7/[PSR-7] response allowing the access of the body response
  13. as array or object. This means you can access the API response as in 7.x, no BC break here! :angel:
  14. - we changed the `ConnectionPool` in `NodePool`. The `connection` naming was ambigous since the objects are nodes (hosts)
  15. [discrete]
  16. ==== Specific changes
  17. The following functions has been removed:
  18. - `ClientBuilder::getEndpoint()`
  19. - `ClientBuilder::getRegisteredNamespacesBuilders()`
  20. - `ClientBuilder::getRegisteredNamespacesBuilders()`
  21. - `ClientBuilder::defaultHandler()`
  22. - `ClientBuilder::multiHandler()`
  23. - `ClientBuilder::singleHandler()`
  24. - `ClientBuilder::setConnectionFactory()`
  25. - `ClientBuilder::setConnectionPool()`, you can use `ClientBuilder::setNodePool` instead
  26. - `ClientBuilder::setEndpoint()`
  27. - `ClientBuilder::registerNamespace()`
  28. - `ClientBuilder::setTransport()`, you can specify an HTTP PSR-18 client using `ClientBuilder::setHttpClient()`
  29. - `ClientBuilder::setHandler()`
  30. - `ClientBuilder::setTracer()`, you can only set a Logger using `ClientBuilder::setLogger()`
  31. - `ClientBuilder::setSerializer()`
  32. - `ClientBuilder::setConnectionParams()`, you can use `ClientBuilder::setHttpClientOptions()` instead
  33. - `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see [here](https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector) for more information
  34. - `ClientBuilder::setSniffOnStart()`
  35. - `ClientBuilder::includePortInHostHeader()`
  36. We removed the special `client` parameter passed in `$params` endpoints. In details:
  37. - `$params['client']['never_retry']`
  38. - `$params['client']['verbose']`
  39. - `$params['client']['port_in_header']`
  40. - `$params['client']['future']`, you can set HTTP async using `Client::setAsync(true)`
  41. - `$params['client']['ignore']`, you can disable the Exception using `Client::setResponseException(false)`