{"id":13562894,"url":"https://github.com/elastic/elasticsearch-php","last_synced_at":"2026-02-04T13:44:33.286Z","repository":{"id":8287730,"uuid":"9826184","full_name":"elastic/elasticsearch-php","owner":"elastic","description":"Official PHP client for Elasticsearch.","archived":false,"fork":false,"pushed_at":"2025-04-22T09:38:16.000Z","size":10681,"stargazers_count":5338,"open_issues_count":5,"forks_count":981,"subscribers_count":469,"default_branch":"main","last_synced_at":"2025-04-28T14:56:56.442Z","etag":null,"topics":["client","elasticsearch","php"],"latest_commit_sha":null,"homepage":"https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"texastribune/generator-tt-newsapps","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elastic.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2013-05-03T01:25:46.000Z","updated_at":"2025-04-23T10:53:14.000Z","dependencies_parsed_at":"2024-03-27T14:56:00.124Z","dependency_job_id":"13ddeb6f-684e-416e-8751-1207eb2b07e3","html_url":"https://github.com/elastic/elasticsearch-php","commit_stats":{"total_commits":2214,"total_committers":184,"mean_commits":"12.032608695652174","dds":0.4489611562782294,"last_synced_commit":"ab0fdb43f9e69f0d0539028d8b0b56cdf3328d85"},"previous_names":[],"tags_count":141,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elastic%2Felasticsearch-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elastic","download_url":"https://codeload.github.com/elastic/elasticsearch-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252544065,"owners_count":21765278,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","elasticsearch","php"],"created_at":"2024-08-01T13:01:13.215Z","updated_at":"2026-02-04T13:44:33.213Z","avatar_url":"https://github.com/elastic.png","language":"PHP","funding_links":[],"categories":["PHP","Table of Contents","目录","Data Management \u0026 Processing","搜索 Search","数据搜索引擎","Clients \u0026 SDKs"],"sub_categories":["Search","搜索 Search","Database \u0026 Cloud Management","资源传输下载"],"readme":"\u003cp align=\"center\"\u003e\n     \u003cimg src=\"https://github.com/elastic/elasticsearch-py/raw/main/docs/images/logo-elastic-glyph-color.svg\" width=\"20%\" alt=\"Elastic logo\" /\u003e\n\u003c/p\u003e\n\n# Elasticsearch PHP client\n\n[![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)\n\nThis is the official PHP client for\n[Elasticsearch](https://www.elastic.co/elasticsearch/).\n\nYou can run [Elasticsearch](https://www.elastic.co/elasticsearch) and [Kibana](https://www.elastic.co/kibana) on your local machine using this command:\n\n```bash\ncurl -fsSL https://elastic.co/start-local | sh\n```\nor **[sign-up](https://cloud.elastic.co/registration?elektra=en-ess-sign-up-page)**\n**for a free trial of Elastic Cloud**.\n\n## Contents\n\n- [Installation](#installation)\n- [Connecting](#connecting)\n- [Usage](#usage)\n- [Versioning](#versioning)\n- [Backward Incompatible Changes](#backward-incompatible-changes-boom)\n- [Mock the Elasticsearch client](#mock-the-elasticsearch-client)\n- [FAQ](#faq-)\n- [Contribute](#contribute-)\n- [License](#license-)\n\n***\n\n## Installation\n\nRefer to the [Installation section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_installation)\nof the getting started documentation.\n\n## Connecting\n\nRefer to the [Connecting section](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_connecting)\nof the getting started documentation.\n\n## Usage\n\nThe `elasticsearch-php` client offers 500+ endpoints for interacting with\nElasticsearch. A list of all these endpoints is available in the\n[official documentation](https://www.elastic.co/guide/en/elasticsearch/reference/current/rest-apis.html)\nof Elasticsearch APIs.\n\nHere we reported the basic operation that you can perform with the client:\nindex, search and delete.\n\n- [Creating an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_creating_an_index)\n- [Indexing a document](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_indexing_documents)\n- [Getting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_getting_documents)\n- [Searching documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_searching_documents)\n- [Updating documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_updating_documents)\n- [Deleting documents](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_documents)\n- [Deleting an index](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/getting-started-php.html#_deleting_an_index)\n\n### Versioning\n\nThis client is versioned and released alongside Elasticsearch server.\n\nTo guarantee compatibility, use the most recent version of this library within\nthe major version of the corresponding Enterprise Search implementation.\n\nFor example, for Elasticsearch `8.16`, use `8.16` of this library or above, but\nnot `9.0`.\n\n## Compatibility\n\nThe Elasticsearch client is compatible with currently maintained PHP versions.\n\nLanguage clients are forward compatible; meaning that clients support\ncommunicating with greater or equal minor versions of Elasticsearch without\nbreaking. It does not mean that the client automatically supports new features\nof newer Elasticsearch versions; it is only possible after a release of a new\nclient version. For example, a 8.12 client version won't automatically support\nthe new features of the 8.13 version of Elasticsearch, the 8.13 client version\nis required for that. Elasticsearch language clients are only backwards\ncompatible with default distributions and without guarantees made.\n\n| Elasticsearch Version | Elasticsearch-PHP Branch | Supported |\n| --------------------- | ------------------------ | --------- |\n| main                  | main                     |           |\n| 9.x                   | 9.x                      | 9.x       |\n| 8.x                   | 8.x                      | 8.x       |\n\n## Backward Incompatible Changes :boom:\n\nThe 9.0.0 version of `elasticsearch-php` contains the same architecture of 8.x.\nIt supports [PSR-7](https://www.php-fig.org/psr/psr-7/) for HTTP messages and\n[PSR-18](https://www.php-fig.org/psr/psr-18/) for HTTP client communications.\n\nWe tried to avoid BC breaks for `9.x`, here the main changes:\n\n- **Compatibility with Elasticsearch 9.0:** All changes and additions to Elasticsearch APIs for its 9.0 release are reflected in this release.\n- **Serverless client merged in:** the `elastic/elasticsearch-serverless` client is being deprecated, and its functionality has been merged back into this client. This should have zero impact on the way the client works by default. If an endpoint is available in serverless, the PHP function will contains a `@group serverless` phpdoc attribute.\nIf you try to use an endpoint that is not available in serverless you will get a `410` HTTP error with a message as follows:\n\"this endpoint exists but is not available when running in serverless mode\".\nThe 9.0.0 client can recognize that it is communicating with a serverless instance if you are using a URL managed by Elastic (e.g. `*.elastic.cloud`).\nIf you are using a proxy, the client will be able to recognize that the host is serverless from the first response. Alternatively, you can explicitly indicate that the host is serverless using the `Client::setServerless(true)` function (`false` by default).\n- **New transport library with PSR-18 cURL client as default:** we've removed the Guzzle dependency from the client. By default, the built-in cURL-based HTTP client will be used if no other PSR-18 compatible clients are detected. See release [9.0.0](https://github.com/elastic/elastic-transport-php/releases/tag/v9.0.0) of elastic-transport-php.\n\nYou can have a look at the [BREAKING_CHANGES](BREAKING_CHANGES.md) file for more\ninformation.\n\n## Mock the Elasticsearch client\n\nIf you need to mock the Elasticsearch client you just need to mock a\n[PSR-18](https://www.php-fig.org/psr/psr-18/) HTTP Client.\n\nFor instance, you can use the\n[php-http/mock-client](https://github.com/php-http/mock-client) as follows:\n\n```php\nuse Elastic\\Elasticsearch\\ClientBuilder;\nuse Elastic\\Elasticsearch\\Response\\Elasticsearch;\nuse Http\\Mock\\Client;\nuse Nyholm\\Psr7\\Response;\n\n$mock = new Client(); // This is the mock client\n\n$client = ClientBuilder::create()\n    -\u003esetHttpClient($mock)\n    -\u003ebuild();\n\n// This is a PSR-7 response\n$response = new Response(\n    200, \n    [Elasticsearch::HEADER_CHECK =\u003e Elasticsearch::PRODUCT_NAME],\n    'This is the body!'\n);\n$mock-\u003eaddResponse($response);\n\n$result = $client-\u003einfo(); // Just calling an Elasticsearch endpoint\n\necho $result-\u003easString(); // This is the body!\n```\n\nWe are using the `ClientBuilder::setHttpClient()` to set the mock client.\nYou can specify the response that you want to have using the\n`addResponse($response)` function. As you can see the `$response` is a PSR-7\nresponse object. In this example we used the `Nyholm\\Psr7\\Response` object from\nthe [nyholm/psr7](https://github.com/Nyholm/psr7) project. If you are using\n[PHPUnit](https://phpunit.de/) you can even mock the `ResponseInterface` as\nfollows:\n\n```php\n$response = $this-\u003ecreateMock('Psr\\Http\\Message\\ResponseInterface');\n```\n\n**Notice**: we added a special header in the HTTP response. This is the product\ncheck header, and it is required for guarantee that `elasticsearch-php` is\ncommunicating with an Elasticsearch server 8.0+.\n\nFor more information you can read the\n[Mock client](https://docs.php-http.org/en/latest/clients/mock-client.html)\nsection of PHP-HTTP documentation.\n\n## FAQ 🔮\n\n### Where do I report issues with the client?\n\nIf something is not working as expected, please open an\n[issue](https://github.com/elastic/elasticsearch-php/issues/new).\n\n### Where else can I go to get help?\n\nYou can checkout the\n[Elastic community discuss forums](https://discuss.elastic.co/).\n\n## Contribute 🚀\n\nWe welcome contributors to the project. You can refer to the [CONTRIBUTING](CONTRIBUTING.md)\nguide for more information.\n\nThanks in advance for your contribution! :heart:\n\n## License 📗\n\n[MIT](LICENSE) © [Elastic](https://www.elastic.co/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Felasticsearch-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felastic%2Felasticsearch-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felastic%2Felasticsearch-php/lists"}