Skip to content

Commit

Permalink
Support silex 2 / pimple (#12)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
mvanbaak authored and cjyclaire committed May 25, 2016
1 parent bfa73d1 commit a1a2ef5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 16 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
[![Latest Stable Version](https://poser.pugx.org/aws/aws-sdk-php-silex/v/stable.png)](https://packagist.org/packages/aws/aws-sdk-php-silex)
[![Total Downloads](https://poser.pugx.org/aws/aws-sdk-php-silex/downloads.png)](https://packagist.org/packages/aws/aws-sdk-php-silex)

A simple Silex service provider for including the [AWS SDK for PHP](https://github.com/aws/aws-sdk-php).
A simple Silex 2 / Pimple 3 service provider for including the [AWS SDK for PHP](https://github.com/aws/aws-sdk-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

Expand All @@ -15,7 +19,7 @@ The AWS Service Provider can be installed via [Composer](http://getcomposer.org)
```json
{
"require": {
"aws/aws-sdk-php-silex": "~2.0"
"aws/aws-sdk-php-silex": "~3.0"
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"require": {
"php": ">=5.5",
"aws/aws-sdk-php": "~3.0",
"silex/silex": "1.*"
"silex/silex": "^2.0"
},
"autoload": {
"psr-4": {
Expand All @@ -28,7 +28,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
"dev-master": "3.0-dev"
}
},
"require-dev": {
Expand Down
17 changes: 7 additions & 10 deletions src/AwsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,26 @@
namespace Aws\Silex;

use Aws\Sdk;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Silex\Application;
use Silex\ServiceProviderInterface;

/**
* AWS SDK for PHP service provider for Silex applications
*/
class AwsServiceProvider implements ServiceProviderInterface
{
const VERSION = '2.0.2';
const VERSION = '3.0.0';

public function register(Application $app)
public function register(Container $container)
{
$app['aws'] = $app->share(function (Application $app) {
$config = isset($app['aws.config']) ? $app['aws.config'] : [];
$container['aws'] = function (Application $container) {
$config = isset($container['aws.config']) ? $container['aws.config'] : [];

return new Sdk($config + ['ua_append' => [
'Silex/' . Application::VERSION,
'SXMOD/' . self::VERSION,
]]);
});
}

public function boot(Application $app)
{
};
}
}
2 changes: 0 additions & 2 deletions tests/AwsServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public function testRegisterAwsServiceProvider()
],
)
));
$provider->boot($app);

// Get an instance of a client (S3) to use for testing
$s3 = $app['aws']->createS3();
Expand Down Expand Up @@ -66,7 +65,6 @@ public function testNoConfigProvided()
],
)
));
$provider->boot($app);

// Instantiate a client, which should trigger an exception for missing configs
$s3 = $app['aws']->createS3();
Expand Down

0 comments on commit a1a2ef5

Please sign in to comment.