PHPackages                             wonsulting/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. wonsulting/opensearch-client

ActiveLibrary[API Development](/categories/api)

wonsulting/opensearch-client
============================

The official PHP OpenSearch client integrated with Laravel

2.0.1(3d ago)0188↓34.1%1MITPHP ^7.4 || ^8.0

Since Oct 17Compare

[ Source](https://github.com/wonsulting/opensearch-client)[ Packagist](https://packagist.org/packages/wonsulting/opensearch-client)[ Fund](https://paypal.me/babenkoi)[ Fund](https://ko-fi.com/ivanbabenko)[ RSS](/packages/wonsulting-opensearch-client/feed)WikiDiscussions Synced today

READMEChangelogDependencies (5)Versions (10)Used By (1)

OpenSearch Client
=================

[](#opensearch-client)

The official PHP OpenSearch client integrated with Laravel.

Contents
--------

[](#contents)

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

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

[](#compatibility)

RequirementSupported versionsPHP8.2 – 8.4Laravel11 – 13OpenSearch (opensearch-php client)2.x> Laravel 13 requires PHP 8.3 or newer.

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

[](#installation)

The library can be installed via Composer:

```
composer require wonsulting/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 one options array per connection.

```
return [
    'default' => env('OPENSEARCH_CONNECTION', 'default'),
    'connections' => [
        'default' => [
            'base_uri' => env('OPENSEARCH_BASE_URI', 'http://localhost:9200'),
            // Optional — any Guzzle request option passes through to the factory:
            // 'auth' => [env('OPENSEARCH_USERNAME'), env('OPENSEARCH_PASSWORD')],
            // 'verify' => env('OPENSEARCH_VERIFY_TLS', true),
            // 'retries' => (int) env('OPENSEARCH_RETRIES', 0),
        ],
    ],
];
```

Each connection is the options array for the SDK's PSR-18 `OpenSearch\GuzzleClientFactory`. `base_uri` is required (a single URI with an explicit scheme); `auth`, `verify`, and any other Guzzle request option pass straight through. `retries` is the one package-level key — it is applied as the factory's `maxRetries`, not sent to Guzzle.

> **Migrating from v2.x:** the per-connection `hosts` array was replaced by a single `base_uri`, and `OPENSEARCH_HOST`became `OPENSEARCH_BASE_URI`. A connection that still contains a `hosts` key throws `InvalidConfigurationException`rather than silently dropping hosts — the new API expresses exactly one host per connection.

To swap the HTTP client (e.g. Symfony), add AWS SigV4 signing, or attach a logger, bind your own `OpenSearch\ClientFactoryInterface` in the container and `ClientBuilder` will use it instead of the default `GuzzleClientFactory`:

```
$this->app->bind(OpenSearch\ClientFactoryInterface::class, fn () => new OpenSearch\SymfonyClientFactory());
```

If you need still 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')
        ]);
    }
}
```

Documentation
-------------

[](#documentation)

Maintainer-facing docs live in [`docs/`](docs/):

- [Architecture](docs/architecture.md) — package internals, the three classes, DI flow, config schema, and caching semantics.
- [Runbook](docs/runbook.md) — setup, tests, quality tooling, CI mapping, smoke test, and release process.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance99

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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 ~679 days

Total

3

Last Release

3d ago

Major Versions

0.1.0 → 2.0.02023-04-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c764594a5302db666f3e72a34e32af56f198d210a8729e4a9901881d8a6f33f?d=identicon)[jpangborn](/maintainers/jpangborn)

---

Tags

phpclientlaravelopensearch

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/wonsulting-opensearch-client/health.svg)](https://phpackages.com/packages/wonsulting-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.7k9.5M90](/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

639574.3k8](/packages/google-gemini-php-laravel)[mozex/anthropic-laravel

Laravel integration for the Anthropic API: facade, config publishing, install command, testing fakes, messages, streaming, tool use, thinking, and batches.

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

Gemini API client for Laravel

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

PHPackages © 2026

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