You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Register the AWS Service Provider in your Silex application and provide your AWS SDK for PHP configuration to the app
in the aws.config key. $app['aws.config'] should contain an array of configuration options or the path to a
configuration file. This value is passed directly into new Aws\Sdk.
<?phprequire__DIR__ . '/vendor/autoload.php';
useAws\Silex\AwsServiceProvider;
useSilex\Application;
$app = newApplication();
$app->register(newAwsServiceProvider(), array(
'aws.config' => array(
'version' => 'latest',
'region' => 'us-east-1',
)
));
// Note: You can also specify a path to a config file// (e.g., 'aws.config' => '/path/to/aws/config/file.php')$app->match('/', function () use ($app) {
// Get the Amazon S3 client$s3 = $app['aws']->createS3();
// Create a list of the buckets in your account$output = "<ul>\n";
foreach ($s3->getListBucketsIterator() as$bucket) {
$output .= "<li>{$bucket['Name']}</li>\n";
}
$output .= "</ul>\n";
return$output;
});
$app->run();