Skip to content

Commit 813b977

Browse files
committed
Merge pull request #52 from runmybusiness/laravel5
Laravel 5 Compatibility
2 parents a114872 + 37649f2 commit 813b977

12 files changed

+183
-309
lines changed

README.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest Stable Version](https://poser.pugx.org/aws/aws-sdk-php-laravel/v/stable.png)](https://packagist.org/packages/aws/aws-sdk-php-laravel)
44
[![Total Downloads](https://poser.pugx.org/aws/aws-sdk-php-laravel/downloads.png)](https://packagist.org/packages/aws/aws-sdk-php-laravel)
55

6-
A simple [Laravel 4](http://laravel.com/) service provider for including the [AWS SDK for PHP](https://github.com/aws/aws-sdk-php).
6+
A simple [Laravel 5](http://laravel.com/) service provider for including the [AWS SDK for PHP](https://github.com/aws/aws-sdk-php).
77

88
## Installation
99

@@ -13,7 +13,7 @@ The AWS Service Provider can be installed via [Composer](http://getcomposer.org)
1313
```json
1414
{
1515
"require": {
16-
"aws/aws-sdk-php-laravel": "1.*"
16+
"aws/aws-sdk-php-laravel": "~2.0"
1717
}
1818
}
1919
```
@@ -27,21 +27,29 @@ php composer.phar update
2727

2828
To use the AWS Service Provider, you must register the provider when bootstrapping your Laravel application.
2929

30-
Publish the package configuration using Artisan.
30+
By default, the package uses the following environment variables to auto-configure the plugin without modification:
31+
```
32+
AWS_ACCESS_KEY_ID
33+
AWS_SECRET_ACCESS_KEY
34+
AWS_REGION // default = us-east-1
35+
AWS_CONFIG_FILE // default = null
36+
```
37+
38+
To customize the configuration file, publish the package configuration using Artisan.
3139

3240
```sh
33-
php artisan config:publish aws/aws-sdk-php-laravel
41+
php artisan vendor:publish
3442
```
3543

36-
Update your settings in the generated `app/config/packages/aws/aws-sdk-php-laravel` configuration file.
44+
Update your settings in the generated `app/config/aws.php` configuration file.
3745

3846
```php
39-
return array(
47+
return [
4048
'key' => 'YOUR_AWS_ACCESS_KEY_ID',
4149
'secret' => 'YOUR_AWS_SECRET_KEY',
4250
'region' => 'us-east-1',
4351
'config_file' => null,
44-
);
52+
];
4553
```
4654

4755
Find the `providers` key in your `app/config/app.php` and register the AWS Service Provider.

composer.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "aws/aws-sdk-php-laravel",
33
"homepage": "http://aws.amazon.com/sdkforphp2",
4-
"description": "A simple Laravel 4 service provider for including the AWS SDK for PHP.",
5-
"keywords": ["laravel","laravel 4","aws","amazon","sdk","s3","ec2","dynamodb"],
4+
"description": "A simple Laravel 5 service provider for including the AWS SDK for PHP.",
5+
"keywords": ["laravel", "laravel 5", "aws", "amazon", "sdk", "s3", "ec2", "dynamodb"],
66
"type":"library",
77
"license":"Apache-2.0",
88
"authors":[
@@ -12,15 +12,15 @@
1212
}
1313
],
1414
"require": {
15-
"php": ">=5.3.3",
16-
"aws/aws-sdk-php": "~2.2",
17-
"illuminate/foundation": "4.*",
18-
"illuminate/support": "4.*"
15+
"php": ">=5.4.0",
16+
"aws/aws-sdk-php": "~2.4",
17+
"illuminate/support": "~5.0"
1918
},
2019
"require-dev": {
21-
"phpunit/phpunit": "3.7.*"
20+
"laravel/framework": "~5.0",
21+
"phpunit/phpunit": "~4.0"
2222
},
2323
"autoload": {
24-
"psr-0": { "Aws\\Laravel": "src/" }
24+
"psr-4": { "Aws\\Laravel\\": "src/" }
2525
}
2626
}
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,21 @@
1-
<?php
2-
/**
3-
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License").
6-
* You may not use this file except in compliance with the License.
7-
* A copy of the License is located at
8-
*
9-
* http://aws.amazon.com/apache2.0
10-
*
11-
* or in the "license" file accompanying this file. This file is distributed
12-
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13-
* express or implied. See the License for the specific language governing
14-
* permissions and limitations under the License.
15-
*/
16-
17-
return array(
1+
<?php return [
182

193
/*
204
|--------------------------------------------------------------------------
215
| Your AWS Credentials
226
|--------------------------------------------------------------------------
237
|
248
| In order to communicate with an AWS service, you must provide your AWS
25-
| credentials including your AWS Access Key ID and your AWS Secret Key.
9+
| credentials including your AWS Access Key ID and AWS Secret Access Key.
2610
|
2711
| To use credentials from your credentials file or environment or to use
2812
| IAM Instance Profile credentials, please remove these config settings from
29-
| your config or make sure they are null. For more information see:
13+
| your config or make sure they are null. For more information, see:
3014
| http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html
3115
|
3216
*/
33-
'key' => null, // Your AWS Access Key ID
34-
'secret' => null, // Your AWS Secret Access Key
17+
'key' => env('AWS_ACCESS_KEY_ID'),
18+
'secret' => env('AWS_SECRET_ACCESS_KEY'),
3519

3620
/*
3721
|--------------------------------------------------------------------------
@@ -40,13 +24,11 @@
4024
|
4125
| Many AWS services are available in multiple regions. You should specify
4226
| the AWS region you would like to use, but please remember that not every
43-
| service is available in every region.
44-
|
45-
| These are the regions: us-east-1, us-west-1, us-west-2, us-gov-west-1
46-
| eu-west-1, sa-east-1, ap-northeast-1, ap-southeast-1, ap-southeast-2
27+
| service is available in every region. To see what regions are available,
28+
| see: http://docs.aws.amazon.com/general/latest/gr/rande.html
4729
|
4830
*/
49-
'region' => 'us-east-1',
31+
'region' => env('AWS_REGION', 'us-east-1'),
5032

5133
/*
5234
|--------------------------------------------------------------------------
@@ -61,6 +43,6 @@
6143
| information: http://docs.aws.amazon.com/aws-sdk-php-2/guide/latest/configuration.html#using-a-custom-configuration-file
6244
|
6345
*/
64-
'config_file' => null,
46+
'config_file' => env('AWS_CONFIG_FILE'),
6547

66-
);
48+
];

phpunit.xml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit backupGlobals="false"
33
backupStaticAttributes="false"
4-
bootstrap="./tests/bootstrap.php"
4+
bootstrap="./vendor/autoload.php"
55
colors="false"
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"
@@ -16,6 +16,12 @@
1616
</testsuite>
1717
</testsuites>
1818

19+
<php>
20+
<env name="AWS_ACCESS_KEY_ID" value="foo"/>
21+
<env name="AWS_SECRET_ACCESS_KEY" value="bar"/>
22+
<env name="AWS_REGION" value="baz"/>
23+
</php>
24+
1925
<filter>
2026
<whitelist addUncoveredFilesFromWhitelist="false">
2127
<directory suffix=".php">src</directory>

src/Aws/Laravel/AwsFacade.php

-38
This file was deleted.

src/Aws/Laravel/AwsServiceProvider.php

-85
This file was deleted.

src/AwsFacade.php

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php namespace Aws\Laravel;
2+
3+
use Aws\Common\Client\AwsClientInterface;
4+
use Illuminate\Support\Facades\Facade;
5+
6+
/**
7+
* Facade for the AWS service
8+
*
9+
* @method static AwsClientInterface get($name, $throwAway = false) Get a client from the service builder
10+
*/
11+
class AwsFacade extends Facade {
12+
13+
/**
14+
* Get the registered name of the component.
15+
*
16+
* @return string
17+
*/
18+
protected static function getFacadeAccessor()
19+
{
20+
return 'aws';
21+
}
22+
23+
}

src/AwsServiceProvider.php

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php namespace Aws\Laravel;
2+
3+
use Aws\Common\Aws;
4+
use Illuminate\Support\ServiceProvider;
5+
6+
/**
7+
* AWS SDK for PHP service provider for Laravel applications
8+
*/
9+
class AwsServiceProvider extends ServiceProvider {
10+
11+
/**
12+
* Indicates if loading of the provider is deferred.
13+
*
14+
* @var bool
15+
*/
16+
protected $defer = true;
17+
18+
/**
19+
* Bootstrap the configuration
20+
*
21+
* @return void
22+
*/
23+
public function boot()
24+
{
25+
$config = realpath(__DIR__ . '/../config/config.php');
26+
27+
$this->mergeConfigFrom($config, 'aws');
28+
29+
$this->publishes([$config => config_path('aws.php')], 'config');
30+
}
31+
32+
/**
33+
* Register the service provider.
34+
*
35+
* @return void
36+
*/
37+
public function register()
38+
{
39+
$this->app->singleton('aws', function ($app) {
40+
// Retrieve config.
41+
$config = $app['config']->get('aws');
42+
if (isset($config['config_file'])) {
43+
$config = $config['config_file'];
44+
}
45+
46+
return Aws::factory($config);
47+
});
48+
49+
$this->app->alias('aws', 'Aws\Common\Aws');
50+
}
51+
52+
/**
53+
* Get the services provided by the provider.
54+
*
55+
* @return array
56+
*/
57+
public function provides()
58+
{
59+
return ['aws', 'Aws\Common\Aws'];
60+
}
61+
62+
}

0 commit comments

Comments
 (0)