directorytree/opensearch-client 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

directorytree/opensearch-client

Composer 安装命令:

composer require directorytree/opensearch-client

包简介

A Laravel integration for the official OpenSearch PHP client

README 文档

README

A Laravel integration for the official OpenSearch PHP client.

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');

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-22