Skip to content

xp-forge/aws

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS Core for the XP Framework

Build status on GitHub XP Framework Module BSD Licence Requires PHP 7.0+ Supports PHP 8.0+ Latest Stable Version

Provides common AWS functionality in an lightweight library (only 10% of the size of the official PHP SDK!)

Invoking a lambda

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());

Sharing a S3 resource

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);

See also