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]>
  • Loading branch information
kimpepper committed Oct 24, 2024
1 parent 1866e6e commit df01728
Show file tree
Hide file tree
Showing 300 changed files with 5,071 additions and 4,857 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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@abc7163](https://github.com/opensearch-project/opensearch-api-specification/commit/abc7163185733c1008fb7c28117cf36c051f3292)
- 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
45 changes: 37 additions & 8 deletions samples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,46 @@
* 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();

$info = $client->info();

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

// Symfony example

$symfonyPsr18Client = (new \Symfony\Component\HttpClient\Psr18Client())->withOptions([
'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',
],
]);

$transport = new OpenSearch\Transport($symfonyPsr18Client, $requestFactory);

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

$info = $client->info();
Loading

0 comments on commit df01728

Please sign in to comment.