opensearch-project/opensearch-php
Official PHP client for OpenSearch. Provides a convenient, low-level API for indexing and searching documents, managing clusters and indices, and calling OpenSearch endpoints from Laravel or any PHP app. Supports modern PHP versions and common auth options.
ServiceProvider (e.g., OpenSearchServiceProvider) to manage client instances, configuration, and retries.jenssegers/laravel-mongodb) for hybrid data models.json_encode flags) that may conflict with Laravel’s strict typing.Guzzle).pthreads or reactphp), which the client does not natively support.429 Too Many Requests) must be mapped to Laravel’s exception hierarchy (e.g., OpenSearchRateLimitException). The client’s error responses may need wrapping in custom exceptions.Mockery or Laravel’s Http facade). Integration tests may need a local OpenSearch instance (e.g., Dockerized).config('opensearch.hosts'))?env() or Vault integration suffice?elasticsearch/elasticsearch), what are the breaking changes in query syntax or API structure?$this->app->singleton(OpenSearchClient::class, function ($app) {
return OpenSearch\ClientBuilder::create()
->setHosts($app['config']['opensearch.hosts'])
->setRetryOnStatus([429, 500, 503])
->build();
});
config/opensearch.php for host, auth, and retry settings, with environment overrides.class OpenSearchRepository {
public function search(string $index, array $query): array {
return $this->client->search([
'index' => $index,
'body' => ['query' => $query]
]);
}
}
IndexCreated, SearchExecuted) via Laravel’s event system for observability or side effects.boolQuery(), matchQuery()).collect() to transform legacy query structures.Searchable trait can delegate to the OpenSearch client).Aws\Credentials\CredentialProvider) via the client’s auth options.config/opensearch.php and environment variables for hosts/auth.composer require with --update-with-dependencies cautiously.composer.json if OpenSearch server upgrades introduce API changes.config:cache to avoid runtime config file parsing overhead.OpenSearchConnectionException).try {
$response = $client->search(...);
} catch (OpenSearch\Common\Exceptions\ExceptionInterface $e) {
Log::error('OpenSearch error', ['response' => $e->getResponse()]);
throw new \RuntimeException('Search failed', 0, $e);
}
pthreads pool for queue workers).ClientBuilder) to handle transient failures.| Failure Scenario | Impact |
How can I help you explore Laravel packages today?