Skip to content
CAI
Software that uses CAICheck a score

elastic/elasticsearch-php

50.8

Weak · 19 September 2026

29.4k

lines of production code

PHP

primary language

1

measurement over time

CAI band scale
CAI lens gauges

What this system is

This system is the official Elasticsearch PHP client library, providing a modern, PSR-18 compliant interface for interacting with Elasticsearch clusters and Elastic Serverless environments. It facilitates core data operations such as indexing, searching, and bulk processing, while offering specialized helpers for dense vector handling, ES\|QL query construction, and paginated result iteration. The library ensures robust observability through OpenTelemetry integration and supports flexible HTTP transport via pluggable adapters like Guzzle and Symfony.

How it got here

2013 — v9.0 architecture modernization

8 changes.

This period focused on establishing the foundational structure for the elasticsearch-php v9.0 release, which mandates PHP 8.1+ and adopts PSR-18 transport standards. The work involved a comprehensive cleanup of legacy code, including the removal of obsolete client, transport, and connection pool classes, alongside a major overhaul of dependencies and testing infrastructure.

2022 — Elasticsearch PHP client v9.5.0 release

9 changes.

This period focused on releasing Elasticsearch PHP client version 9.5.0, introducing a standardized ClientInterface, OpenTelemetry instrumentation, and specific exception classes for precise error handling. The update also added a new response wrapper for multi-format deserialization, pluggable HTTP client adapters with SSL support, and regenerated endpoints to align with Elasticsearch 8.x and 9.x API specifications.

2023–2026 — ES\|QL and vector search enhancements

7 changes.

This period focused on expanding the PHP client's capabilities for modern Elasticsearch features, including comprehensive support for ES\|QL query building and scroll-based search iterators. Significant work was also done to optimize vector operations through new bulk indexing helpers and dense vector packing utilities, accompanied by extensive unit testing and CI pipeline automation.

Features

Added dense vector bulk upload benchmark example

A new PHP script, \examples/dense\_vector\_benchmark.php\, has been added to demonstrate high-performance bulk indexing of dense vectors. The example benchmarks ingestion speeds by comparing standard float32 vectors against base64-packed vectors, allowing users to evaluate performance differences across various chunk sizes and repetition counts.

examples · high confidence

Added scroll-based search iterators for Elasticsearch

New iterator classes have been added to the Helper/Iterators namespace to support paginated search results via Elasticsearch's scroll API. SearchResponseIterator manages the lifecycle of scroll windows, handling the initial search request, fetching subsequent pages using the scroll ID, and automatically clearing the scroll context upon destruction. SearchHitIterator wraps the response iterator to flatten the paginated structure, allowing users to iterate directly over individual search hits across all pages while exposing the total hit count.

src/Helper/Iterators · high confidence

Elasticsearch PHP Client version 9.5.0 release

The Elasticsearch PHP client has been updated to version 9.5.0. This release introduces a new \ClientInterface\ to standardize client interactions, adds support for configuring the client for Elastic Serverless environments, and includes a new \Utility\ class for environment variable handling and variable name formatting. The \ClientBuilder\ has been updated to support these new configuration options, and the client now sends an API compatibility header (\compatible-with=9\) and an \elastic-api-version\ header (\2023-10-31\) with requests.

src · high confidence

Expanded ES\|QL query builder with new processing commands

The ES\|QL query builder in src/Helper/Esql has been refactored into a modular class structure and extended with support for additional ES\|QL processing commands. New capabilities include CHANGE\_POINT for detecting metric anomalies, COMPLETION for LLM text generation, DISSECT and GROK for log parsing, ENRICH for data enrichment, FORK for parallel query branches, FUSE for merging results, LOOKUP\_JOIN for external data joins, MMR for vector similarity search, REGISTERED\_DOMAIN for domain extraction, and RERANK for AI-driven result reordering. The builder now also supports the METRICS\_INFO and TS\_INFO commands for deployment and time-series metadata, alongside existing commands like EVAL, STATS, and SORT, allowing users to construct more complex and modern ES\|QL queries programmatically.

src/Helper/Esql · high confidence

Initial repository structure and configuration for elasticsearch-php

This change establishes the foundational structure for the elasticsearch-php client repository. It introduces the \AGENTS.md\ file to provide setup and development workflow instructions for AI coding agents, and \BREAKING\_CHANGES.md\ to document architectural shifts and API removals across major versions (notably the PHP 8.1+ requirement and PSR-18 transport changes in 9.0). The repository now includes a comprehensive \CHANGELOG.md\ tracking releases from 9.5.0 back to 6.0, and a \README.md\ detailing installation, usage, and compatibility. Configuration files for static analysis (\phpstan.neon\), testing (\phpunit.xml.dist\, \phpunit-integration-tests.xml\, and YAML test suites), and build infrastructure (\catalog-info.yaml\, \.gitattributes\, \.gitignore\) are added to standardize the development environment.

(repo-wide) · high confidence

Introduction of specific exception classes for the Elasticsearch PHP client

The library now provides a dedicated set of exception classes within the \Elastic\\Elasticsearch\\Exception\ namespace, all implementing the \ElasticsearchException\ interface. This includes specific types for HTTP errors (\ClientResponseException\ for 4xx, \ServerResponseException\ for 5xx), configuration issues (\ConfigException\), content type mismatches (\ContentTypeException\), and bulk helper operations (\BulkHelperException\, which includes response details via \ResponseTrait\). Other added exceptions cover array access, authentication, invalid arguments, missing parameters, and product checks, allowing for more precise error handling.

src/Exception · high confidence

New Buildkite CI pipeline for PHP client tests

Added a new Buildkite CI configuration that automates the testing of the PHP client against Elasticsearch. The setup includes a Dockerfile for the test environment, a pipeline definition that runs tests across PHP versions 8.1 through 8.5, and scripts to launch Elasticsearch nodes (supporting both free and platinum security configurations) and execute integration tests.

.buildkite · high confidence

New Elasticsearch response wrapper with multi-format deserialization

The \src/Response\ area now introduces the \Elasticsearch\ class and its \ElasticsearchInterface\, providing a dedicated wrapper around PSR-7 HTTP responses. This component enables users to easily deserialize response bodies into arrays, objects, or strings based on the Content-Type header (supporting JSON, NDJSON, CSV, and XML). It also includes logic to detect Serverless responses via the API version header and automatically throws specific client or server exceptions for 4xx and 5xx status codes when configured.

src/Response · high confidence

New HTTP client adapter system with SSL configuration support

The transport layer now supports pluggable HTTP client adapters (Guzzle, Symfony, and a new ElasticCurl implementation) via a unified interface, allowing users to configure SSL certificates, keys, verification, and CA bundles consistently across different underlying HTTP libraries.

src/Transport · high confidence

New bulk indexing helper and dense vector packing utility

Added a new Bulk helper class in src/Helper/Bulk.php that simplifies batch operations against Elasticsearch by accepting an iterator of actions, automatically chunking them by count (default 500) or size (default 10MB), and returning operation statistics and optional detailed results. The helper supports index, create, partial update, and delete actions via dedicated static methods. Additionally, a new Vectors helper in src/Helper/Vectors.php provides a packDenseVector method that encodes float arrays into a base64-encoded binary format for efficient vector uploads.

src/Helper · high confidence

Removals

Removal of legacy ElasticSearch exception classes and empty serializer

The \ElasticSearch\\Common\\Exceptions\ namespace has been cleaned up by removing the \BadMethodCallException\, \InvalidArgumentException\, \UnexpectedValueException\ classes and the \ElasticSearchException\ interface, which previously extended standard PHP exceptions. Additionally, the empty \JSONSerializer\ class in \ElasticSearch\\Serializers\ has been deleted. These changes remove unused or placeholder code from the library's common and serialization components.

src/ElasticSearch/Common, src/ElasticSearch/Serializers · high confidence

Removed legacy ElasticSearch Client and Transport classes

The legacy \Client\ and \Transport\ classes in the \src/ElasticSearch\ directory have been removed. This eliminates the previous implementation that relied on a Pimple-based dependency injection container for managing connection pools, selectors, and transport logic, effectively cleaning up the codebase by discarding these specific components.

src/ElasticSearch · high confidence

Removed placeholder ElasticSearch Connection class

The stub implementation of the \ElasticSearch\\Connections\\Connection\ class has been removed from the codebase. This class previously served only as a placeholder, printing constructor arguments without providing any functional connection logic, and its deletion cleans up unused code.

src/ElasticSearch/Connections · high confidence

Removed placeholder ElasticSearch connection pool and selector classes

The \src/ElasticSearch/ConnectionPool\ directory has been removed, deleting the \ConnectionPool\ class and all associated selector implementations (\SelectorInterface\, \RoundRobinSelector\, \BackupSelector\, \RandomSelector\). These files were empty stubs or incomplete placeholders that did not contain functional logic, effectively cleaning up unused infrastructure from the codebase.

src/ElasticSearch/ConnectionPool · high confidence

Behavioural changes

Generated Elasticsearch PHP client endpoints now include OpenTelemetry support

The API endpoint classes in src/Endpoints have been regenerated to include OpenTelemetry (OTel) instrumentation. Each endpoint method now calls addOtelAttributes to attach trace context to outgoing requests, enabling distributed tracing for client operations. This change is visible across all generated endpoint files (e.g., AsyncSearch, Autoscaling, Cat, Ccr, Cluster, Connector), which now consistently integrate OTel attributes into their HTTP request lifecycle.

src/Endpoints · high confidence

Updated API endpoints and traits for Elasticsearch 8.x compatibility

The \src/Traits\ directory has been regenerated to align with the latest Elasticsearch API specifications (versions 8.4 through 9.1). This update introduces new endpoint methods such as \bulk\, \clearScroll\, and \closePointInTime\ in \ClientEndpointsTrait\, while \EndpointTrait\ now handles parameter conversion (arrays to comma-separated lists, booleans to strings) and manages API compatibility headers for serverless environments. Additionally, \MessageResponseTrait\ has been updated to implement PSR-7 v2.0 interfaces, and \NamespaceTrait\ includes new namespace accessors for features like \AsyncSearch\, \Esql\, and \Streams\.

src/Traits · high confidence

Test coverage

Added comprehensive test suite for Elasticsearch PHP client; Added integration tests for Elasticsearch client features; Added tests for EndpointTrait request building and header handling; Added tests for the Elasticsearch response object; Added unit tests for SearchHitIterator and SearchResponseIterator; Added unit tests for the ES\|QL Query helper; Removed legacy PHPUnit tests for Client, ConnectionPool, and Transport.

Dependencies

Major dependency overhaul and PHP 8.1+ requirement

The project has been updated to require PHP 8.1 or higher, dropping support for older PHP versions. Core dependencies have been significantly modernized: the package now relies on \elastic/transport\ ^9.0 and standard PSR interfaces (\psr/http-client\ ^1.0, \psr/http-message\ ^2.0, \psr/log\ ^2.0\|^3.0) instead of older bundled or specific implementations. Development tooling has also been upgraded to PHPUnit ^10.0, PHPStan ^2.1, and Mockery ^1.6, while the namespace structure has shifted to PSR-4 under \Elastic\\Elasticsearch\\\.

(dependencies) · high confidence

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

How this codebase got here

Baseline

  • First survey — no prior run to compare against. CAI 51.

Lenses

  • Code Health 100
  • Architecture 66
  • Maturity 59
  • Readiness 47
  • Security 43

Changes since last survey

  • 300 commits — 262 feature/other, 38 fixes

By area

  • (root) — 48 commits
  • (repo) — 40 commits
  • src/Endpoints — 38 commits
  • .github/workflows — 32 commits
  • tests/BuildPHPUnitClass.php — 15 commits
  • docs/reference — 13 commits
  • src/Helper — 13 commits
  • .buildkite/pipeline.yml — 8 commits
  • docs/release-notes — 7 commits
  • .github/make.sh — 6 commits
  • docs/index-custom-title-page.html — 6 commits
  • .buildkite/certs — 5 commits
  • .ci/jobs — 5 commits
  • .buildkite/Dockerfile — 4 commits
  • src/Traits — 4 commits
  • util/YamlTests.php — 4 commits
  • .buildkite/build-tests.sh — 3 commits
  • .buildkite/run-repository.sh — 3 commits
  • docs/docset.yml — 3 commits
  • tests/Utility.php — 3 commits

Notable commits

  • fix: Backport: Fixed the Yaml tests + updated wipeCluster
  • fix: Changed psr-7 versions to 1.1 and 2.0 + added regression test (#1344)
  • fix: FIxed RestSpecRunnner with build_id for rest-resource
  • fix: Fix Response\Elasticsearch::offsetGet() return type declaration (#1385)
  • fix: Fixed --esonly for YAML tests
  • fix: Fixed --esonly option for start-local
  • fix: Fixed Docker for buildkite
  • fix: Fixed PHP 8.2 tests
  • fix: Fixed TEST_SUITE in build-tests
  • fix: Fixed TEST_SUITE in build-tests
  • fix: Fixed TypeError: Cannot assing for platinum tests
  • fix: Fixed Yaml test + added tests to skip
  • fix: Fixed github action warnings
  • fix: Fixed issue with set in YAML specification + interpolation for PHP 8.2
  • fix: Fixed link in breaking changes doc (#1388)
  • fix: Fixed profiling tests + skipped tests
  • fix: Fixed run-tests.sh name
  • fix: Fixed setHosts in docs
  • fix: Fixed the tests with property type declarations
  • fix: Fixed yaml_test in github action
  • …and 280 more

Written by watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.

Survey your own repository

elastic/elasticsearch-php was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.

About this page

  • The score is its most recent published measurement, taken on 19 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
  • Measured at commit 14793597efab4efa16eccae0e1f1dc2f4d4601b4 — the exact code this score is about.
  • Scored under rubric-2026.09.15 — the same rubric and the same method as every other entry in this index.
  • Measured by watchdog.canine.dev using codehealth-analyzer preprod-13a154b7f5d1.