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, CredentialProvider};
use util\cmd\Console;
$s3= (new ServiceEndpoint('s3', CredentialProvider::default()))
->in('eu-central-1')
->using('my-bucket')
;
$link= $s3->sign('/path/to/resource.png', timeout: 180);
Console::writeLine($link);
use com\amazon\aws\api\SignatureV4;
use com\amazon\aws\{ServiceEndpoint, CredentialProvider, S3Key};
use io\File;
use util\cmd\Console;
$s3= (new ServiceEndpoint('s3', CredentialProvider::default()))
->in('eu-central-1')
->using('my-bucket')
;
$file= new File($argv[1]);
$file->open(File::READ);
try {
$transfer= $s3->resource(new S3Key('target', $file->filename))->open('PUT', [
'x-amz-content-sha256' => SignatureV4::UNSIGNED, // Or calculate from file
'Content-Type' => 'text/plain',
'Content-Length' => $file->size(),
]);
while (!$file->eof()) {
$transfer->write($file->read());
}
$response= $transfer->finish();
Console::writeLine($response);
} finally {
$file->close();
}