PHP code example of wizacha / aws-signature-middleware

1. Go to this page and download the library: Download wizacha/aws-signature-middleware 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/ */

    

wizacha / aws-signature-middleware example snippets



$credentials = new \Aws\Credentials\Credentials('id', 'secret');
$signature = new \Aws\Signature\SignatureV4('es', 'eu-west-1');

$middleware = new \Wizacha\Middleware\AwsSignatureMiddleware($credentials, $signature);
$defaultHandler = \Elasticsearch\ClientBuilder::defaultHandler();
$awsHandler = $middleware($defaultHandler);

$clientBuilder =  \Elasticsearch\ClientBuilder::create();

$clientBuilder
    ->setHandler($awsHandler)
    ->setHosts(['endpoint.eu-west-1.es.amazonaws.com:80'])
;
$client = $clientBuilder->build();