New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

directorytree/opensearch-client

A Laravel integration for the official OpenSearch PHP client
7,016 3
Install
composer require directorytree/opensearch-client
Latest Version:v1.0.0
PHP:^8.2
Laravel:11 · 12 · 13
License:MIT
Last Updated:Oct 8, 2026
Links: GitHub  ·  Packagist
Maintainer: stevebauman

OpenSearch Client

A Laravel integration for the OpenSearch PHP client.

Tests Total Downloads Latest Version License

Installation · Configuration · Usage


Installation

Install the package with Composer:

composer require directorytree/opensearch-client

Configuration

Publish the configuration file:

php artisan vendor:publish --provider="DirectoryTree\OpenSearchClient\OpenSearchClientServiceProvider"

The published config/opensearch-client.php file defines the default connection and any named OpenSearch connections:

return [
    'default' => env('OPENSEARCH_CONNECTION', 'default'),

    'connections' => [
        'default' => [
            'base_uri' => env('OPENSEARCH_HOST', 'http://localhost:9200'),
        ],
    ],
];

Each connection is passed directly to OpenSearch\GuzzleClientFactory.

Usage

Resolve DirectoryTree\OpenSearchClient\OpenSearchManager from the container to access OpenSearch clients:

namespace App\Console\Commands;

use DirectoryTree\OpenSearchClient\OpenSearchManager;
use Illuminate\Console\Command;

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

    protected $description = 'Creates an index';

    public function handle(OpenSearchManager $opensearch): void
    {
        $client = $opensearch->default();

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

You can also resolve named connections:

$client = $opensearch->connection('write');

You may also use the facade:

use DirectoryTree\OpenSearchClient\Facades\OpenSearch;

$client = OpenSearch::connection('write');

Credits

This package builds on a lot of the foundation and prior work from Ivan Babenko and his Elasticsearch Laravel ecosystem packages.

We're grateful for the work he has shared with the Laravel community. If this package helps your work, consider supporting Ivan through GitHub Sponsors.

Related Packages

wonsulting/opensearch-client

The official PHP OpenSearch client integrated with Laravel

1,843 0
wonsulting/opensearch-adapter

Adapter for official PHP OpenSearch client

1,770 0
timkley/weaviate-php

A PHP HTTP Client for the Weaviate REST API

91,153 36
shufo/laravel-opensearch

An easy way to use the official PHP OpenSearch client in your Laravel applicatio...

8,844 6
timkley/awork-php-sdk

A PHP HTTP Client for the awork API

2,787 1

Version History

Version Released PHP Laravel License
v1.0.0 ^8.2 ^11.0|^12.0|^13.0 MIT