- How do I install opensearch-project/opensearch-php in a Laravel app?
- Run composer require opensearch-project/opensearch-php. Then bind the client as a singleton in a Laravel service provider using config values for hosts, credentials, and transport options. There is no Laravel-specific auto-discovery package, so register the provider and publish any config manually if needed.
- Is opensearch-php compatible with Laravel and which PHP version do I need?
- The client is framework-agnostic PHP, not a Laravel-specific package, but it integrates cleanly through a Laravel service provider and config. Confirm the client's PHP requirement against your Laravel runtime, such as PHP 8.2 or newer. There is no native Eloquent ORM integration, so wrap search logic in your own service or query builder.
- Does opensearch-php work with Laravel Horizon and Octane long-running workers?
- Yes, but long-running processes need care. The 2.7.1 credential-refresh fix helps with refreshable AWS credentials in Horizon workers, Octane, and scheduler jobs. The client still has no native connection pooling, so tune your transport and avoid rebuilding clients per job unless necessary. Validate credential rotation in staging.
- How do I configure AWS credentials for OpenSearch in Laravel?
- Use a credential provider that can refresh rather than static keys, and rely on the 2.7.1 Refreshable AWS Credentials fix for long-lived processes. Because this is a second attempt at the fix, force a refresh in staging and confirm the client picks up new credentials without restarting. Wrap client construction in a Laravel service provider and inject config from environment variables.
- Does opensearch-php support bulk indexing and async operations in Laravel queues?
- Yes. opensearch-php exposes bulk and async operations, which fit Laravel queues and Horizon for background indexing. Batch documents, monitor partial failures and 429 responses, and add retry and backoff in jobs. Keep request payloads within cluster limits.
- How do I test Laravel search services that use opensearch-php?
- Mock the client's HTTP transport or wrapper service rather than hitting a real cluster. Unit-test query building and response mapping, and use an OpenSearch container for integration tests. In Laravel, bind a fake client in the container for feature tests.
- Which OpenSearch server versions are supported by opensearch-php?
- Check the package COMPATIBILITY.md and validate against your exact OpenSearch cluster version. The client follows the bundled OpenSearch API spec, and 2.7.1 updates that spec additively. Test query syntax and security features when moving between OpenSearch 2.x and 3.x.
- How do I map OpenSearch 429 errors to Laravel exceptions and retries?
- Catch transport or client exceptions and inspect HTTP status codes before mapping them to Laravel exceptions. Create custom exceptions such as OpenSearchRateLimitException for 429 responses and use Laravel retry and backoff in queued jobs. Log cluster response bodies for diagnostics without leaking sensitive data.
- Is opensearch-php a good alternative to elasticsearch-php for Laravel projects?
- opensearch-php is a community-driven open source fork of elasticsearch-php under Apache 2.0 and is the official PHP client for OpenSearch. Choose it when your cluster is OpenSearch; if you run Elasticsearch, use the Elastic client instead. API similarity can reduce migration effort, but validate compatibility and maintenance cadence.
- How do I upgrade opensearch-php from 2.7.0 to 2.7.1 in a Laravel app?
- A 2.7.0 to 2.7.1 upgrade is a patch bump with no expected runtime API or signature changes for common endpoints. The bundled API spec update is additive, and the PHPStan 2.x upgrade is dev-only. Run composer update, test search and index flows, and explicitly validate AWS credential refresh in staging before production.