Skip to content

Commit

Permalink
Switch to PSR interfaces
Browse files Browse the repository at this point in the history
Signed-off-by: Kim Pepper <[email protected]>

Signed-off-by: Kim Pepper <[email protected]>
  • Loading branch information
kimpepper committed Oct 23, 2024
1 parent 1866e6e commit f14e9a2
Show file tree
Hide file tree
Showing 286 changed files with 4,766 additions and 4,296 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
### Fixed
- Fixed upcomming PHP 8.4 deprecations
### Updated APIs
- Updated opensearch-php APIs to reflect [opensearch-api-specification@8255f1b](https://github.com/opensearch-project/opensearch-api-specification/commit/8255f1b3761a9d9653475aee18dee6acd904cf71)
- Updated opensearch-php APIs to reflect [opensearch-api-specification@cb320b5](https://github.com/opensearch-project/opensearch-api-specification/commit/cb320b5482551c4f28afa26ff0d1653332699722)
### Security
### Dependencies
Expand Down
34 changes: 24 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,33 @@
}
],
"require": {
"php": "^7.3 || ^8.0",
"ext-json": ">=1.3.7",
"php": "^8.1",
"ext-curl": "*",
"ezimuel/ringphp": "^1.2.2",
"ext-json": ">=1.3.7",
"php-http/async-client-implementation": "^1.0",
"php-http/discovery": "^1.20",
"php-http/guzzle7-adapter": "^1.0",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "^1.0",
"psr/http-factory": "^1.1",
"psr/http-factory-implementation": "^2.4",
"psr/http-message": "^2.0",
"psr/http-message-implementation": "^1.0",
"psr/log": "^1|^2|^3",
"symfony/yaml": "*"
},
"require-dev": {
"ext-zip": "*",
"aws/aws-sdk-php": "^3.0",
"friendsofphp/php-cs-fixer": "^3.0",
"mockery/mockery": "^1.2",
"phpstan/phpstan": "^1.7.15",
"phpstan/phpstan-mockery": "^1.1.0",
"phpunit/phpunit": "^9.3",
"symfony/finder": "~4.0 || ~5.0"
"friendsofphp/php-cs-fixer": "^v3.64",
"guzzlehttp/psr7": "^2.7",
"mockery/mockery": "^1.6",
"phpstan/phpstan": "^1.12",
"phpstan/phpstan-mockery": "^1.1",
"phpunit/phpunit": "^9.6",
"symfony/finder": "^6.4|^7.0",
"symfony/http-client": "^7.1",
"symfony/http-client-contracts": "^3.5"
},
"suggest": {
"monolog/monolog": "Allows for client-level logging and tracing",
Expand All @@ -54,7 +65,10 @@
}
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"php-http/discovery": true
}
},
"scripts": {
"php-cs": [
Expand Down
44 changes: 37 additions & 7 deletions samples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,47 @@
* SPDX-License-Identifier: Apache-2.0
*/

use OpenSearch\Client;

require_once __DIR__ . '/vendor/autoload.php';

$client = OpenSearch\ClientBuilder::fromConfig([
'Hosts' => [
'https://localhost:9200'
],
'BasicAuthentication' => ['admin', getenv('OPENSEARCH_PASSWORD')],
'Retries' => 2,
'SSLVerification' => false
// Guzzle example

$guzzleClient = new \GuzzleHttp\Client([
'base_uri' => 'https://localhost:9200',
'auth' => ['admin', getenv('OPENSEARCH_PASSWORD')],
'verify' => false,
'retries' => 2,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'User-Agent' => sprintf('opensearch-php/%s (%s; PHP %s)', Client::VERSION, PHP_OS, PHP_VERSION),
]
]);
$requestFactory = new \OpenSearch\RequestFactory();
$transport = new OpenSearch\Transport($guzzleClient, $requestFactory);

$client = (new \OpenSearch\ClientBuilder($transport))->build();

$client = new OpenSearch\Client($transport, $requestFactory, $httpFactory);
$info = $client->info();

echo "{$info['version']['distribution']}: {$info['version']['number']}\n";

// Symfony example

$symfonyClient = \Symfony\Component\HttpClient\HttpClient::create([
'base_uri' => 'https://localhost:9200',
'auth_basic' => ['admin', getenv('OPENSEARCH_PASSWORD')],
'verify_peer' => false,
'max_retries' => 2,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
],
]);

$client = new OpenSearch\Client($symfonyClient);
$info = $client->info();

echo "{$info['version']['distribution']}: {$info['version']['number']}\n";
Loading

0 comments on commit f14e9a2

Please sign in to comment.