PHPackages                             babenkoivan/elastic-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. babenkoivan/elastic-client

ActiveLibrary[Search &amp; Filtering](/categories/search)

babenkoivan/elastic-client
==========================

The official PHP Elasticsearch client integrated with Laravel

v4.0.1(9mo ago)554.5M↓30.4%116MITPHPPHP ^8.2CI passing

Since May 1Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/babenkoivan/elastic-client)[ Packagist](https://packagist.org/packages/babenkoivan/elastic-client)[ Fund](https://ko-fi.com/ivanbabenko)[ Fund](https://paypal.me/babenkoi)[ RSS](/packages/babenkoivan-elastic-client/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (5)Versions (12)Used By (6)

Elastic Client
==============

[](#elastic-client)

[![Latest Stable Version](https://camo.githubusercontent.com/8bcfcc8d5f508337fca94effce15a1823f9d7e400efc27153305595427fef3e9/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d636c69656e742f762f737461626c65)](https://packagist.org/packages/babenkoivan/elastic-client)[![Total Downloads](https://camo.githubusercontent.com/550f1f475ce44e8fad936a0f0a8fd47f79fdefe5b85c602bd18cbf396c6cf639/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/babenkoivan/elastic-client)[![License](https://camo.githubusercontent.com/e4d33a47e6a18c6edd906be645110bf876199d14dba4912188b03b2a53b4544c/68747470733a2f2f706f7365722e707567782e6f72672f626162656e6b6f6976616e2f656c61737469632d636c69656e742f6c6963656e7365)](https://packagist.org/packages/babenkoivan/elastic-client)[![Tests](https://github.com/babenkoivan/elastic-client/workflows/Tests/badge.svg)](https://github.com/babenkoivan/elastic-client/actions?query=workflow%3ATests)[![Code style](https://github.com/babenkoivan/elastic-client/workflows/Code%20style/badge.svg)](https://github.com/babenkoivan/elastic-client/actions?query=workflow%3A%22Code+style%22)[![Static analysis](https://github.com/babenkoivan/elastic-client/workflows/Static%20analysis/badge.svg)](https://github.com/babenkoivan/elastic-client/actions?query=workflow%3A%22Static+analysis%22)[![Donate PayPal](https://camo.githubusercontent.com/0b8a275d67dfb2aa74ac299fa07b7fce95217f6620448d88cf05ff9e3653e9bf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f6e6174652d70617970616c2d626c7565)](https://paypal.me/babenkoi)

 [![Support the project!](https://camo.githubusercontent.com/201ef269611db7eb6b5d08e9f756ab8980df3014b64492770bdf13a6ed924641/68747470733a2f2f6b6f2d66692e636f6d2f696d672f676974687562627574746f6e5f736d2e737667)](https://ko-fi.com/ivanbabenko)

---

The official PHP Elasticsearch client integrated with Laravel.

Contents
--------

[](#contents)

- [Compatibility](#compatibility)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)

Compatibility
-------------

[](#compatibility)

The current version of Elastic Client has been tested with the following configuration:

- PHP 8.2
- Elasticsearch 9.x
- Laravel 12.x

If your project uses older Elasticsearch, Laravel, or PHP version check [the previous major version](https://github.com/babenkoivan/elastic-client/tree/v3.1.1#compatibility) of the package.

Installation
------------

[](#installation)

The library can be installed via Composer:

```
composer require babenkoivan/elastic-client
```

Configuration
-------------

[](#configuration)

To change the client settings you need to publish the configuration file first:

```
php artisan vendor:publish --provider="Elastic\Client\ServiceProvider"
```

In the newly created `config/elastic.client.php` file you can define the default connection name and describe multiple connections using configuration hashes. You can read more about building the client from a configuration hash [here](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/node_pool.html#config-hash).

```
return [
    'default' => env('ELASTIC_CONNECTION', 'default'),
    'connections' => [
        'default' => [
            'hosts' => [
                env('ELASTIC_HOST', 'localhost:9200'),
            ],
            // configure basic authentication
            'basicAuthentication' => [
                env('ELASTIC_USERNAME'),
                env('ELASTIC_PASSWORD'),
            ],
            // configure HTTP client (Guzzle by default)
            'httpClientOptions' => [
                'timeout' => 2,
            ],
        ],
    ],
];
```

If you need more control over the client creation, you can create your own client builder:

```
use Elastic\Elasticsearch\ClientInterface;
use Elastic\Client\ClientBuilderInterface;

class MyClientBuilder implements ClientBuilderInterface
{
    public function default(): ClientInterface
    {
        // should return a client instance for the default connection
    }

    public function connection(string $name): ClientInterface
    {
        // should return a client instance for the connection with the given name
    }
}
```

Do not forget to register the builder in your application service provider:

```
class MyAppServiceProvider extends Illuminate\Support\ServiceProvider
{
    public function register()
    {
        $this->app->singleton(ClientBuilderInterface::class, MyClientBuilder::class);
    }
}
```

Usage
-----

[](#usage)

Use `Elastic\Client\ClientBuilderInterface` to get access to the client instance:

```
namespace App\Console\Commands;

use Elastic\Elasticsearch\ClientInterface;
use Elastic\Client\ClientBuilderInterface;
use Illuminate\Console\Command;

class CreateIndex extends Command
{
    protected $signature = 'create:index {name}';

    protected $description = 'Creates an index';

    public function handle(ClientBuilderInterface $clientBuilder)
    {
        // get a client for the default connection
        $client = $clientBuilder->default();
        // get a client for the connection with name "write"
        $client = $clientBuilder->connection('write');

        $client->indices()->create([
            'index' => $this->argument('name')
        ]);
    }
}
```

###  Health Score

58

—

FairBetter than 98% of packages

Maintenance58

Moderate activity, may be stable

Popularity57

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor1

Top contributor holds 94.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~202 days

Recently: every ~129 days

Total

11

Last Release

275d ago

Major Versions

v1.2.0 → v2.0.02022-07-26

v2.1.0 → v3.0.02024-06-18

v3.1.0 → v4.0.02025-10-25

PHP version history (4 changes)v1.0.1PHP ^7.2

v1.2.0PHP ^7.2 || ^8.0

v2.0.0PHP ^7.4 || ^8.0

v3.0.0PHP ^8.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25812954?v=4)[Ivan Babenko](/maintainers/babenkoivan)[@babenkoivan](https://github.com/babenkoivan)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (66 commits)")[![stevebauman](https://avatars.githubusercontent.com/u/6421846?v=4)](https://github.com/stevebauman "stevebauman (3 commits)")[![jopplt](https://avatars.githubusercontent.com/u/93759030?v=4)](https://github.com/jopplt "jopplt (1 commits)")

---

Tags

clientelasticsearchlaravelphpphpclientlaravelelasticsearchelastic

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/babenkoivan-elastic-client/health.svg)

```
[![Health](https://phpackages.com/badges/babenkoivan-elastic-client/health.svg)](https://phpackages.com/packages/babenkoivan-elastic-client)
```

###  Alternatives

[mailerlite/laravel-elasticsearch

An easy way to use the official PHP ElasticSearch client in your Laravel applications.

935628.9k2](/packages/mailerlite-laravel-elasticsearch)[jeroen-g/explorer

Next-gen Elasticsearch driver for Laravel Scout.

399693.0k](/packages/jeroen-g-explorer)[babenkoivan/elastic-scout-driver

Elasticsearch driver for Laravel Scout

2764.3M8](/packages/babenkoivan-elastic-scout-driver)[babenkoivan/elastic-scout-driver-plus

Extension for Elastic Scout Driver

2873.2M4](/packages/babenkoivan-elastic-scout-driver-plus)[babenkoivan/elastic-migrations

Elasticsearch migrations for Laravel

1962.8M9](/packages/babenkoivan-elastic-migrations)[babenkoivan/elastic-adapter

Adapter for official PHP Elasticsearch client

404.6M9](/packages/babenkoivan-elastic-adapter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
