Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Simple Silex service provider for including the AWS SDK for PHP
branch: master

AWS Service Provider for Silex

Latest Stable Version Total Downloads

A simple Silex service provider for including the AWS SDK for PHP.


The AWS Service Provider can be installed via Composer by requiring the aws/aws-sdk-php-silex package in your project's composer.json.

    "require": {
        "aws/aws-sdk-php-silex": "1.*"


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 Aws\Common\Aws::factory().


require __DIR__ . '/vendor/autoload.php';

use Aws\Silex\AwsServiceProvider;
use Silex\Application;

$app = new Application();

$app->register(new AwsServiceProvider(), array(
    'aws.config' => array(
        'key'    => 'your-aws-access-key-id',
        'secret' => 'your-aws-secret-access-key',
        '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']->get('s3');

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



Something went wrong with that request. Please try again.