PHP code example of aws / aws-sdk-php-silex
1. Go to this page and download the library: Download aws/aws-sdk-php-silex 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/ */
aws / aws-sdk-php-silex example snippets
ws\Silex\AwsServiceProvider;
use Silex\Application;
$app = new Application();
$app->register(new AwsServiceProvider(), 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();
json
{
"ws/aws-sdk-php-silex": "~3.0"
}
}