PHP code example of xp-forge / aws

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

    

xp-forge / aws example snippets


use com\amazon\aws\{Credentials, ServiceEndpoint};
use util\Secret;
use util\cmd\Console;
use util\log\Logging;

$credentials= new Credentials($accessKey, new Secret($secretKey));

$api= (new ServiceEndpoint('lambda', $credentials))->in('eu-central-1')->version('2015-03-31');
$api->setTrace(Logging::all()->toConsole());

$r= $api->resource('/functions/greet/invocations')->transmit(['name' => getenv('USER')]);

Console::writeLine($r);
Console::writeLine($r->value());

use com\amazon\aws\{ServiceEndpoint, Credentials};
use util\cmd\Console;

$api= new ServiceEndpoint('s3', new Credentials(
  getenv('AWS_ACCESS_KEY_ID'),
  getenv('AWS_SECRET_ACCESS_KEY'),
  getenv('AWS_SESSION_TOKEN')
));
$link= $api->in('eu-central-1')->using('my-bucket')->sign('/path/to/resource.png', timeout: 180);

Console::writeLine($link);