Skip to content

Latest commit

 

History

History
63 lines (44 loc) · 2.16 KB

UPGRADING.md

File metadata and controls

63 lines (44 loc) · 2.16 KB

Upgrading OpenSearch PHP Client

Upgrading to >= 2.4.0

The openseach-php library removes the hard-coded dependency on the Guzzle HTTP client and switches to the following PSR interfaces:

You can continue to use Guzzle, but will need to configure it as a PSR-18 HTTP Client.

PSR-18 HTTP Client Interfaces

Starting with opensearch-php 2.4.0 you can use any PSR-18 compatible HTTP client.

To simplify creating a Client, we provide two factories to create PSR-18 HTTP clients for Guzzle and Symfony HTTP clients since opensearch-php 2.5.0.

Configuring Guzzle HTTP Client in 2.4.x

To configure Guzzle as a PSR HTTP Client with the similar configuration to opensearch-php 1.x you can use the following example:

Ensure the Guzzle packages are installed via composer:

composer require guzzlehttp/guzzle
$client = (new \OpenSearch\GuzzleClientFactory())->create([
    'base_uri' => 'https://localhost:9200',
    'auth' => ['admin', getenv('OPENSEARCH_PASSWORD')],
    'verify' => false,
]);

// Send a request to the 'info' endpoint.
$info = $client->info();

Configuring Symfony HTTP Client in 2.4.x

You can configure Symfony HTTP Client as a PSR HTTP Client using the following example:

composer require symfony/http-client
$client = (new \OpenSearch\SymfonyClientFactory())->create([
    'base_uri' => 'https://localhost:9200',
    'auth_basic' => ['admin', getenv('OPENSEARCH_PASSWORD')],
    'verify_peer' => false,
]);

// Send a request to the 'info' endpoint.
$info = $client->info();