Skip to content

Commit 9008eae

Browse files
committed
Merge remote-tracking branch 'origin/main' into catalog-info-buildkite-pipeline
2 parents 5be834d + bff3c3e commit 9008eae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2667
-174
lines changed

.buildkite/pipeline.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ steps:
55
env:
66
PHP_VERSION: "{{ matrix.php }}"
77
TEST_SUITE: "{{ matrix.suite }}"
8-
STACK_VERSION: 8.10-SNAPSHOT
8+
STACK_VERSION: 8.14.0-SNAPSHOT
99
matrix:
1010
setup:
1111
suite:
1212
- "free"
1313
- "platinum"
1414
php:
15+
- "8.3-cli"
1516
- "8.2-cli"
1617
- "8.1-cli"
1718
- "8.0-cli"

.github/workflows/license.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v4
1212

1313
- name: Check license headers
1414
run: |

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ jobs:
99

1010
strategy:
1111
matrix:
12-
php-version: [7.4, 8.0, 8.1, 8.2]
12+
php-version: [7.4, 8.0, 8.1, 8.2, 8.3]
1313
os: [ubuntu-latest]
14-
es-version: [8.9-SNAPSHOT]
14+
es-version: [8.14-SNAPSHOT]
1515

1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3
18+
uses: actions/checkout@v4
1919

2020
- name: Use PHP ${{ matrix.php-version }}
2121
uses: shivammathur/setup-php@v2
@@ -30,7 +30,7 @@ jobs:
3030
id: composercache
3131
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
3232
- name: Cache dependencies
33-
uses: actions/cache@v3
33+
uses: actions/cache@v4
3434
with:
3535
path: ${{ steps.composercache.outputs.dir }}
3636
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.json') }}

.github/workflows/unified-release.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 276 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 74 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
<img align="right" width="auto" height="auto" src="https://www.elastic.co/static-res/images/elastic-logo-200.png"/>
22

3-
Elasticsearch PHP client
4-
========================
3+
# Elasticsearch PHP client
54

65
[![Build status](https://github.com/elastic/elasticsearch-php/workflows/PHP%20test/badge.svg)](https://github.com/elastic/elasticsearch-php/actions) [![Latest Stable Version](https://poser.pugx.org/elasticsearch/elasticsearch/v/stable)](https://packagist.org/packages/elasticsearch/elasticsearch) [![Total Downloads](https://poser.pugx.org/elasticsearch/elasticsearch/downloads)](https://packagist.org/packages/elasticsearch/elasticsearch)
76

8-
This is the official PHP client for
7+
This is the official PHP client for
98
[Elasticsearch](https://www.elastic.co/elasticsearch/).
109

10+
**[Download the latest version of Elasticsearch](https://www.elastic.co/downloads/elasticsearch)**
11+
or
12+
**[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)**
13+
**for a free trial of Elastic Cloud**.
14+
1115
## Contents
1216

1317
- [Installation](#installation)
@@ -27,73 +31,92 @@ This is the official PHP client for
2731
Refer to the [Installation section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_installation)
2832
of the getting started documentation.
2933

30-
## Connecting
34+
## Connecting
3135

3236
Refer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_connecting)
3337
of the getting started documentation.
3438

3539
## Usage
3640

37-
The `elasticsearch-php` client offers 400+ endpoints for interacting with
38-
Elasticsearch. A list of all these endpoints is available in the
41+
The `elasticsearch-php` client offers 400+ endpoints for interacting with
42+
Elasticsearch. A list of all these endpoints is available in the
3943
[official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html)
4044
of Elasticsearch APIs.
4145

42-
Here we reported the basic operation that you can perform with the client:
46+
Here we reported the basic operation that you can perform with the client:
4347
index, search and delete.
4448

45-
* [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_creating_an_index)
46-
* [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_indexing_documents)
47-
* [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_getting_documents)
48-
* [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_searching_documents)
49-
* [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_updating_documents)
50-
* [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_documents)
51-
* [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_an_index)
49+
- [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_creating_an_index)
50+
- [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_indexing_documents)
51+
- [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_getting_documents)
52+
- [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_searching_documents)
53+
- [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_updating_documents)
54+
- [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_documents)
55+
- [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_an_index)
5256

5357
### Versioning
5458

5559
This client is versioned and released alongside Elasticsearch server.
5660

57-
To guarantee compatibility, use the most recent version of this library within
61+
To guarantee compatibility, use the most recent version of this library within
5862
the major version of the corresponding Enterprise Search implementation.
5963

60-
For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but
64+
For example, for Elasticsearch `7.16`, use `7.16` of this library or above, but
6165
not `8.0`.
6266

67+
## Compatibility
68+
69+
The Elasticsearch client is compatible with currently maintained PHP versions.
70+
71+
Language clients are forward compatible; meaning that clients support
72+
communicating with greater or equal minor versions of Elasticsearch without
73+
breaking. It does not mean that the client automatically supports new features
74+
of newer Elasticsearch versions; it is only possible after a release of a new
75+
client version. For example, a 8.12 client version won't automatically support
76+
the new features of the 8.13 version of Elasticsearch, the 8.13 client version
77+
is required for that. Elasticsearch language clients are only backwards
78+
compatible with default distributions and without guarantees made.
79+
80+
| Elasticsearch Version | Elasticsearch-PHP Branch | Supported |
81+
| --------------------- | ------------------------ | --------- |
82+
| main | main | |
83+
| 8.x | 8.x | 8.x |
84+
| 7.x | 7.x | 7.17 |
85+
6386
## Backward Incompatible Changes :boom:
6487

65-
The 8.0.0 version of `elasticsearch-php` contains a new implementation compared
66-
with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP
67-
messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client
68-
communications.
88+
The 8.0.0 version of `elasticsearch-php` contains a new implementation compared
89+
with 7.x. It supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP
90+
messages and [PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client
91+
communications.
6992

70-
We tried to reduce the BC breaks as much as possible with `7.x` but there are
93+
We tried to reduce the BC breaks as much as possible with `7.x` but there are
7194
some (big) differences:
7295

7396
- we changed the namespace, now everything is under `Elastic\Elasticsearch`
74-
- we used the
75-
[elastic-transport-php](https://github.com/elastic/elastic-transport-php)
97+
- we used the
98+
[elastic-transport-php](https://github.com/elastic/elastic-transport-php)
7699
library for HTTP communications;
77-
- we changed the `Exception` model, using the namespace
78-
`Elastic\Elasticsearch\Exception`. All the exceptions extends the
100+
- we changed the `Exception` model, using the namespace
101+
`Elastic\Elasticsearch\Exception`. All the exceptions extends the
79102
`ElasticsearchException` interface, as in 7.x
80-
- we changed the response type of each endpoints using an
81-
[Elasticsearch](src/Response/Elasticsearch.php) response class. This class
82-
wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the
83-
access of the body response as array or object. This means you can access the
103+
- we changed the response type of each endpoints using an
104+
[Elasticsearch](src/Response/Elasticsearch.php) response class. This class
105+
wraps a a [PSR-7](https://www.php-fig.org/psr/psr-7/) response allowing the
106+
access of the body response as array or object. This means you can access the
84107
API response as in 7.x, no BC break here! :angel:
85-
- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was
108+
- we changed the `ConnectionPool` in `NodePool`. The `connection` naming was
86109
ambigous since the objects are nodes (hosts)
87110

88-
You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more
111+
You can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more
89112
information.
90113

91114
## Mock the Elasticsearch client
92115

93116
If you need to mock the Elasticsearch client you just need to mock a
94117
[PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client.
95118

96-
For instance, you can use the
119+
For instance, you can use the
97120
[php-http/mock-client](https://github.com/php-http/mock-client) as follows:
98121

99122
```php
@@ -122,52 +145,52 @@ echo $result->asString(); // This is the body!
122145
```
123146

124147
We are using the `ClientBuilder::setHttpClient()` to set the mock client.
125-
You can specify the response that you want to have using the
126-
`addResponse($response)` function. As you can see the `$response` is a PSR-7
127-
response object. In this example we used the `Nyholm\Psr7\Response` object from
128-
the [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using
129-
[PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as
148+
You can specify the response that you want to have using the
149+
`addResponse($response)` function. As you can see the `$response` is a PSR-7
150+
response object. In this example we used the `Nyholm\Psr7\Response` object from
151+
the [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using
152+
[PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as
130153
follows:
131154

132155
```php
133156
$response = $this->createMock('Psr\Http\Message\ResponseInterface');
134157
```
135158

136-
**Notice**: we added a special header in the HTTP response. This is the product
137-
check header, and it is required for guarantee that `elasticsearch-php` is
159+
**Notice**: we added a special header in the HTTP response. This is the product
160+
check header, and it is required for guarantee that `elasticsearch-php` is
138161
communicating with an Elasticsearch server 8.0+.
139162

140-
For more information you can read the
141-
[Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html)
163+
For more information you can read the
164+
[Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html)
142165
section of PHP-HTTP documentation.
143166

144167
## FAQ 🔮
145168

146169
### Where do I report issues with the client?
147170

148-
If something is not working as expected, please open an
171+
If something is not working as expected, please open an
149172
[issue](https://github.com/elastic/elasticsearch-php/issues/new).
150173

151174
### Where else can I go to get help?
152175

153-
You can checkout the
176+
You can checkout the
154177
[Elastic community discuss forums](https://discuss.elastic.co/).
155178

156179
## Contribute 🚀
157180

158181
We welcome contributors to the project. Before you begin, some useful info...
159182

160-
+ If you want to contribute to this project you need to subscribe to a
183+
- If you want to contribute to this project you need to subscribe to a
161184
[Contributor Agreement](https://www.elastic.co/contributor-agreement).
162-
+ Before opening a pull request, please create an issue to
185+
- Before opening a pull request, please create an issue to
163186
[discuss the scope of your proposal](https://github.com/elastic/elasticsearch-php/issues).
164-
+ If you want to send a PR for version `8.0` please use the `8.0` branch, for
165-
`8.1` use the `8.1` branch and so on.
166-
+ Never send PR to `master` unless you want to contribute to the development
187+
- If you want to send a PR for version `8.0` please use the `8.0` branch, for
188+
`8.1` use the `8.1` branch and so on.
189+
- Never send PR to `master` unless you want to contribute to the development
167190
version of the client (`master` represents the next major version).
168-
+ Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/).
169-
If you are not familiar with PHPUnit you can have a look at the
170-
[reference](https://phpunit.readthedocs.io/en/9.5/).
191+
- Each PR should include a **unit test** using [PHPUnit](https://phpunit.de/).
192+
If you are not familiar with PHPUnit you can have a look at the
193+
[reference](https://phpunit.readthedocs.io/en/9.5/).
171194

172195
Thanks in advance for your contribution! :heart:
173196

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
"symfony/finder": "~4.0",
2727
"nyholm/psr7": "^1.5",
2828
"php-http/mock-client": "^1.5",
29-
"symfony/http-client": "^5.0|^6.0",
30-
"php-http/message-factory": "^1.1"
29+
"symfony/http-client": "^5.0|^6.0|^7.0",
30+
"psr/http-factory" : "^1.0",
31+
"php-http/message-factory" : "^1.0"
3132
},
3233
"autoload": {
3334
"psr-4": {
@@ -51,7 +52,7 @@
5152
"vendor/bin/phpunit --testdox -c phpunit-integration-cloud-tests.xml"
5253
],
5354
"phpstan": [
54-
"phpstan analyse src --level 2 --no-progress"
55+
"phpstan analyse src --level 2 --no-progress --memory-limit 256M"
5556
]
5657
},
5758
"config": {

docs/breaking-changes.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The following functions has been removed:
3636
- `ClientBuilder::setTracer()`, you can only set a Logger using `ClientBuilder::setLogger()`
3737
- `ClientBuilder::setSerializer()`
3838
- `ClientBuilder::setConnectionParams()`, you can use `ClientBuilder::setHttpClientOptions()` instead
39-
- `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
39+
- `ClientBuilder::setSelector()`, you can set a `Selector` using the `setNodePool`, see https://github.com/elastic/elastic-transport-php/blob/8.x/README.md#use-a-custom-selector[here] for more information
4040
- `ClientBuilder::setSniffOnStart()`
4141
- `ClientBuilder::includePortInHostHeader()`
4242

docs/connecting.asciidoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ docker run --name es01 --net elastic -p 9200:9200 -p 9300:9300 -it docker.elasti
7979
This command creates an `elastic` Docker network and start {es}
8080
using the port `9200` (default).
8181

82-
When you run the docker imnage a password is generated for the `elastic` user
82+
When you run the docker image a password is generated for the `elastic` user
8383
and it's printed to the terminal (you might need to scroll back a bit in the terminal
8484
to view it). You have to copy it since we will need to connect to {es}.
8585

0 commit comments

Comments
 (0)