PHP code example of nekman / aws-ring-http-signer

1. Go to this page and download the library: Download nekman/aws-ring-http-signer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

nekman / aws-ring-http-signer example snippets


use GuzzleHttp\Ring\Client\CurlHandler;
use Aws\Signature\SignatureV4;
use Nekman\AwsRingHttpSigner\AwsRingHttpSignerFactory;

$signature = new SignatureV4($awsService, $awsRegion); // How do I create this? Please consult the AWS documentation for the service you are using.
$awsRingHttpSigner = AwsRingHttpSignerFactory::create($signature);

$defaultHandler = new CurlHandler(); // Or use whatever handler you already have available.
$handler = $awsRingHttpSigner($defaultHandler);

// And you're done! Use the $handler as you normally would

use Elasticsearch\ClientBuilder;
use Nekman\AwsRingHttpSigner\AwsRingHttpSignerFactory;

$awsRingHttpSigner = AwsRingHttpSignerFactory::create($awsRegion);
$handler = $awsRingHttpSigner(ClientBuilder::defaultHandler()); 

$client = ClientBuilder::create()
    ->setHandler($handler)
    ->build();

// And you're done! Use the $client as you normally would

use Nekman\AwsRingHttpSigner\AwsRingHttpSignerFactory;
use Aws\Credentials\CredentialProvider;
use Aws\Credentials\Credentials;

$credentials = new Credentials(getenv("AWS_KEY"), getenv("AWS_SECRET"));
$credentialProvider = CredentialProvider::fromCredentials($credentials);

$awsRingHttpSigner = AwsRingHttpSignerFactory::create($awsRegion, $credentialProvider);