PHPackages                             haridarshan/opensearch-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. [API Development](/categories/api)
4. /
5. haridarshan/opensearch-client

ActiveLibrary[API Development](/categories/api)

haridarshan/opensearch-client
=============================

The official PHP OpenSearch client integrated with Laravel

v1.0.1(2y ago)03.9k↓19.2%1MITPHPPHP ^7.4 || ^8.0

Since Mar 9Pushed 2y agoCompare

[ Source](https://github.com/haridarshan/opensearch-client)[ Packagist](https://packagist.org/packages/haridarshan/opensearch-client)[ RSS](/packages/haridarshan-opensearch-client/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (1)

OpenSearch Client for Laravel
=============================

[](#opensearch-client-for-laravel)

---

The official PHP OpenSearch client integrated with Laravel.

Contents
--------

[](#contents)

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

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

[](#compatibility)

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

- PHP 7.4-8.x
- OpenSearch 2.x
- Laravel 6.x-10.x

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

[](#installation)

The library can be installed via Composer:

```
composer require haridarshan/opensearch-client
```

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

[](#configuration)

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

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

In the newly created `config/opensearch.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('OPENSEARCH_CONNECTION', 'default'),
    'connections' => [
        'default' => [
            'hosts' => [
                env('OPENSEARCH_HOST', 'localhost:9200'),
            ],
            // configure basic authentication
            'basicAuthentication' => [
                env('OPENSEARCH_USERNAME'),
                env('OPENSEARCH_PASSWORD'),
            ],
            'retries' => (int) env('OPENSEARCH_RETRIES', 2),
            // disable SSL Verification
            'sslVerification' => env('OPENSEARCH_SSL_VERIFICATION', false),
            // 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:

```
// see OpenSearch\Laravel\Client\ClientBuilder for the reference
class MyClientBuilder implements OpenSearch\Laravel\Client\ClientBuilderInterface
{
    public function default(): Client
    {
        // should return a client instance for the default connection
    }

    public function connection(string $name): Client
    {
        // 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 `OpenSearch\Laravel\Client\ClientBuilderInterface` to get access to the client instance:

```
namespace App\Console\Commands;

use OpenSearch\Client;
use OpenSearch\Laravel\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

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.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 ~17 days

Total

2

Last Release

783d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5cc037296dcecf54ee9d5584cefdefe081c6a250c66b2d566e341f5051225b7d?d=identicon)[haridarshan](/maintainers/haridarshan)

---

Top Contributors

[![babenkoivan](https://avatars.githubusercontent.com/u/25812954?v=4)](https://github.com/babenkoivan "babenkoivan (50 commits)")[![haridarshan](https://avatars.githubusercontent.com/u/1327607?v=4)](https://github.com/haridarshan "haridarshan (5 commits)")[![renovate[bot]](https://avatars.githubusercontent.com/in/2740?v=4)](https://github.com/renovate[bot] "renovate[bot] (1 commits)")

---

Tags

phpclientlaravelopensearch

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/haridarshan-opensearch-client/health.svg)

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[google-gemini-php/laravel

Google Gemini PHP for Laravel is a supercharged PHP API client that allows you to interact with the Google Gemini AI API

614397.1k4](/packages/google-gemini-php-laravel)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[gemini-api-php/laravel

Gemini API client for Laravel

8915.7k](/packages/gemini-api-php-laravel)

PHPackages © 2026

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