Download the PHP package wa72/elasticsearch-bundle without Composer
On this page you can find all versions of the php package wa72/elasticsearch-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wa72/elasticsearch-bundle
More information about wa72/elasticsearch-bundle
Files in wa72/elasticsearch-bundle
Package elasticsearch-bundle
Short Description Symfony bundle integrating wa72/es-tools with Elasticsearch or OpenSearch
License MIT
Informations about the package elasticsearch-bundle
Wa72\ElasticsearchBundle
Symfony-bundle for working with Elasticsearch or OpenSearch.
Goals and Features:
- provide the official Elasticsearch PHP Client or the OpenSearch PHP Client as a configurable service in Symfony projects
- Integrate the wa72/es-tools library
- provide a console command for managing elasticsearch indices (verify mappings and settings, create new index version, set aliases)
Supported search engines
Each project uses exactly one search engine. Install the bundle together with the client library for that engine:
| Engine | Composer packages | Client class |
|---|---|---|
| Elasticsearch 6.8 / 7.17 | composer require wa72/elasticsearch-bundle elasticsearch/elasticsearch:"^6.8.4\|^7.17" |
Elasticsearch\Client |
| Elasticsearch 8.19 / 9.x | composer require wa72/elasticsearch-bundle elasticsearch/elasticsearch:"^8.19\|^9.0" |
Elastic\Elasticsearch\Client |
| OpenSearch 2.x / 3.x | composer require wa72/elasticsearch-bundle opensearch-project/opensearch-php:^2.7 |
OpenSearch\Client |
For Elasticsearch, the bundle detects the installed client generation (6/7 or 8/9) automatically.
Configuration
Example for OpenSearch:
The OpenSearch client supports only one host. For multi-host setups use the client_service option.
HTTP client
OpenSearch and Elasticsearch 8/9 clients use a PSR-18 HTTP client:
http_client: symfony(default) uses Symfony HttpClient. It is installed together with this bundle, so no extra package is needed.http_client: guzzleuses Guzzle. Install it withcomposer require guzzlehttp/guzzle.
Elasticsearch 6/7 clients always use their built-in Guzzle RingPHP handler, so the setting is ignored there.
Using your own client service
The bundle only configures the hosts. If you need authentication, SSL settings, a scoped Symfony HTTP client or other transport options,
define the client service yourself and point client_service to it:
In this case the bundle does not build a client, and elasticsearch.client is an alias of your service.
Services
elasticsearch.client: the native client (Elasticsearch\Client,Elastic\Elasticsearch\ClientorOpenSearch\Client). When the bundle builds the client, it is also available for autowiring under its class name.elasticsearch.index.<name>: aWa72\ESTools\Indexservice for each configured index.elasticsearch.index_registry/Wa72\ElasticsearchBundle\Services\IndexRegistry: registry of all configured indexes.elasticsearch.clientbuilder: the ElasticsearchClientBuilderwith the configured hosts (Elasticsearch only, not defined whenclient_serviceis set). Kept for backward compatibility.
Console commands
elasticsearch:checkindex: check if the index exists and if its settings and mappings are correctelasticsearch:deleteindex: delete an index
Running the tests
Most tests do not need a search server. They check the configuration, the service definitions, the client factory and the console commands in a booted Symfony application.
The integration tests in tests/Integration need a running server compatible with the installed client.
Select the engine with SEARCH_ENGINE (elasticsearch (default) or opensearch) and the server with ES_HOST
(default: localhost:9200). If the server is not available, these tests are skipped (or fail if CI is set).
All indices created by the tests start with wa72_bundle_test_ and are deleted afterwards.
For example, to test Elasticsearch 9:
To test OpenSearch:
GitHub Actions
The workflow .github/workflows/tests.yml runs the tests with PHP 8.3, 8.4 and 8.5 against
Elasticsearch 6.8, 7.17, 8.19 and 9.5 and OpenSearch 2.19 and 3.9 with Symfony 7.4.
Two additional jobs use Symfony 6.4. Each job installs only the client for its engine.
Run the workflow locally with nektos/act. Use a recent version of act:
older versions (e.g. 0.2.52) do not support actions running on node24, such as the current shivammathur/setup-php.
When working behind an HTTP proxy, pass the proxy settings to the job containers,
e.g. act push -j test --env https_proxy=$https_proxy --env http_proxy=$http_proxy --env no_proxy=localhost,127.0.0.1,search.
All versions of elasticsearch-bundle with dependencies
wa72/es-tools Version ^0.3
symfony/config Version ^6.4|^7
symfony/console Version ^6.4|^7
symfony/dependency-injection Version ^6.4|^7
symfony/http-kernel Version ^6.4|^7
symfony/http-client Version ^6.4|^7
nyholm/psr7 Version ^1.8