Skip to content
Simple Silex service provider for including the AWS SDK for PHP
Branch: master
Clone or download
mvanbaak and cjyclaire Support silex 2 / pimple (#12)
* Support silex 2 / pimple

* Document silex and this provider versions

Since silex 2 / pimple 3 providers are not compatible with version 1 of silex, make sure to document it in the readme and point silex 1 users to the correct branch.
Latest commit a1a2ef5 May 26, 2016
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src Support silex 2 / pimple (#12) May 25, 2016
tests
.gitignore Stop test from having to traverse the whole CredentialsProvider chain… Jun 11, 2015
.travis.yml
LICENSE.md Updated licensing information. Jan 28, 2013
NOTICE.md
README.md
composer.json Support silex 2 / pimple (#12) May 25, 2016
phpunit.xml.dist PSR4 all the things Jun 12, 2015

README.md

AWS Service Provider for Silex

@awsforphp on Twitter Build Status Latest Stable Version Total Downloads

A simple Silex 2 / Pimple 3 service provider for including the AWS SDK for PHP.

note: If you are using the 1.x Silex version, Use [version 2.x] (https://github.com/aws/aws-sdk-php-silex/tree/2.0) of this provider.

Installation

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": "~3.0"
    }
}

Usage

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.

<?php

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

use Aws\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();

Links

You can’t perform that action at this time.