Skip to content

Commit 7c6bf6d

Browse files
committed
Merge pull request #92 from jeskew/GrahamCampbell-patch-1
Fix Lumen support
2 parents 47d805e + f6b2bbf commit 7c6bf6d

8 files changed

+187
-22
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ matrix:
1212
allow_failures:
1313
- php: hhvm
1414

15-
install: travis_retry composer install --no-interaction --prefer-source
15+
install: travis_retry composer install --no-interaction
1616

17-
script: vendor/bin/phpunit
17+
script: make test
1818

CHANGELOG.md

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# CHANGELOG
2+
3+
## next release
4+
5+
* Added test coverage for version 5.2 of both Lumen and Laravel.
6+
7+
## 3.0.3 - 2015-09-18
8+
9+
* Added support for configuring credentials with environmental variables, a ini
10+
file at `~/.aws/credentials`, or with Ec2 instance profiles instead of
11+
requiring their inclusion in the `aws.php` config file.
12+
13+
## 3.0.3 - 2015-08-10
14+
15+
* Removed usage of a dev dependency
16+
17+
## 3.0.1 - 2015-08-05
18+
19+
* Provide version information to SDK user agent
20+
21+
## 3.0.0 - 2015-06-10
22+
23+
* Service provider is now compatible with Laravel 5.1 and Version 3 of the AWS
24+
SDK for PHP.
25+
26+
## 2.0.1 - 2015-06-10
27+
28+
* Service provider is now compatible with Lumen
29+
30+
## 2.0.0 - 2015-03-12
31+
32+
* Updated the service provider to work with Laravel 5.
33+
34+
## 1.1.2 - 2015-02-13
35+
36+
* Added alias to support DI from container.
37+
38+
## 1.1.1 - 2014-05-12
39+
40+
* Updated default module config file to make it more compatible with environment
41+
credentials
42+
43+
## 1.1.0 - 2013-09-03
44+
45+
* Added package-level config that can be published with Artisan
46+
* Updated config loading logic to support package-level config
47+
* Updated config loading logic to support AWS SDK for PHP config files via the
48+
`config_file` key
49+
* Updated code, tests, and the README to support the config refactoring
50+
* This module is now following [semver](http://semver.org/)
51+
52+
## 1.0.4 - 2013-06-20
53+
54+
* Added support for the AWS facade
55+
* Updated `composer.json` to require only specific components of Laravel
56+
* Updated `composer.json` to require version 2.2+ of the AWS SDK for PHP
57+
58+
## 1.0.3 - 2013-04-25
59+
60+
* Update Composer dependencies to work with newer version of the AWS SDK for PHP
61+
and Laravel
62+
63+
## 1.0.2 - 2013-03-11
64+
65+
* Fixed an issue with config retrieval
66+
67+
## 1.0.1 - 2013-03-07
68+
69+
* Improved usage instructions in the README
70+
* Fixed logic for retrieving Laravel version
71+
72+
## 1.0.0 - 2013-02-13
73+
74+
* Initial release.

Makefile

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
test: test-laravel test-lumen
2+
3+
test-laravel:
4+
composer require laravel/framework
5+
vendor/bin/phpunit
6+
make uninstall-laravel
7+
8+
test-lumen:
9+
composer require laravel/lumen-framework
10+
vendor/bin/phpunit
11+
make uninstall-lumen
12+
13+
uninstall-illuminate:
14+
rm -rf vendor/laravel
15+
rm -rf vendor/illuminate
16+
17+
uninstall-laravel: uninstall-illuminate
18+
composer remove laravel/framework
19+
20+
uninstall-lumen: uninstall-illuminate
21+
composer remove laravel/lumen-framework
22+
23+
# Ensures that the TAG variable was passed to the make command
24+
check-tag:
25+
$(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1"))
26+
27+
# Creates a release but does not push it. This task updates the changelog
28+
# with the TAG environment variable, replaces the VERSION constant, ensures
29+
# that the source is still valid after updating, commits the changelog and
30+
# updated VERSION constant, creates an annotated git tag using chag, and
31+
# prints out a diff of the last commit.
32+
tag: check-tag test
33+
@echo Tagging $(TAG)
34+
chag update $(TAG)
35+
sed -i '' -e "s/VERSION = '.*'/VERSION = '$(TAG)'/" src/AwsServiceProvider.php
36+
php -l src/AwsBundle.php
37+
git commit -a -m '$(TAG) release'
38+
chag tag
39+
@echo "Release has been created. Push using 'make release'"
40+
@echo "Changes made in the release commit"
41+
git diff HEAD~1 HEAD

composer.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717
"illuminate/support": "~5.1"
1818
},
1919
"require-dev": {
20-
"laravel/framework": "~5.1",
21-
"phpunit/phpunit": "~4.0"
20+
"phpunit/phpunit": "~4.0|~5.0"
21+
},
22+
"suggest": {
23+
"laravel/framework": "To test the Laravel bindings",
24+
"laravel/lumen-framework": "To test the Lumen bindings"
2225
},
2326
"autoload": {
2427
"psr-4": { "Aws\\Laravel\\": "src/" }

src/AwsServiceProvider.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php namespace Aws\Laravel;
22

33
use Aws\Sdk;
4+
use Illuminate\Foundation\Application as LaravelApplication;
45
use Illuminate\Support\ServiceProvider;
6+
use Laravel\Lumen\Application as LumenApplication;
57

68
/**
79
* AWS SDK for PHP service provider for Laravel applications
@@ -26,8 +28,10 @@ public function boot()
2628
{
2729
$source = realpath(__DIR__ . '/../config/aws.php');
2830

29-
if (class_exists('Illuminate\Foundation\Application', false)) {
31+
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
3032
$this->publishes([$source => config_path('aws.php')]);
33+
} elseif ($this->app instanceof LumenApplication) {
34+
$this->app->configure('aws');
3135
}
3236

3337
$this->mergeConfigFrom($source, 'aws');
@@ -41,7 +45,8 @@ public function boot()
4145
public function register()
4246
{
4347
$this->app->singleton('aws', function ($app) {
44-
$config = $app['config']->get('aws');
48+
$config = $app->make('config')->get('aws');
49+
4550
return new Sdk($config);
4651
});
4752

tests/AwsServiceProviderTest.php

+6-16
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22

33
use Aws\Laravel\AwsFacade as AWS;
44
use Aws\Laravel\AwsServiceProvider;
5-
use Illuminate\Config\Repository;
6-
use Illuminate\Foundation\Application;
5+
use Illuminate\Container\Container;
76

8-
class AwsServiceProviderTest extends \PHPUnit_Framework_TestCase
7+
abstract class AwsServiceProviderTest extends \PHPUnit_Framework_TestCase
98
{
109

1110
public function testFacadeCanBeResolvedToServiceInstance()
@@ -61,24 +60,16 @@ public function testVersionInformationIsProvidedToSdkUserAgent()
6160
}
6261

6362
/**
64-
* @return Application
63+
* @return Container
6564
*/
66-
private function setupApplication()
67-
{
68-
// Create the application such that the config is loaded.
69-
$app = new Application();
70-
$app->setBasePath(sys_get_temp_dir());
71-
$app->instance('config', new Repository());
72-
73-
return $app;
74-
}
65+
abstract protected function setupApplication();
7566

7667
/**
77-
* @param Application $app
68+
* @param Container $app
7869
*
7970
* @return AwsServiceProvider
8071
*/
81-
private function setupServiceProvider(Application $app)
72+
private function setupServiceProvider(Container $app)
8273
{
8374
// Create and register the provider.
8475
$provider = new AwsServiceProvider($app);
@@ -87,5 +78,4 @@ private function setupServiceProvider(Application $app)
8778

8879
return $provider;
8980
}
90-
9181
}
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php namespace Aws\Laravel\Test;
2+
3+
use Illuminate\Config\Repository;
4+
use Illuminate\Foundation\Application;
5+
6+
class LaravelAwsServiceProviderTest extends AwsServiceProviderTest
7+
{
8+
public function setUp()
9+
{
10+
if (!class_exists(Application::class)) {
11+
$this->markTestSkipped();
12+
}
13+
14+
parent::setUp();
15+
}
16+
17+
protected function setupApplication()
18+
{
19+
// Create the application such that the config is loaded.
20+
$app = new Application();
21+
$app->setBasePath(sys_get_temp_dir());
22+
$app->instance('config', new Repository());
23+
24+
return $app;
25+
}
26+
}

tests/LumenAwsServiceProviderTest.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
namespace Aws\Laravel\Test;
3+
4+
use Illuminate\Config\Repository;
5+
use Laravel\Lumen\Application;
6+
7+
class LumenAwsServiceProviderTest extends AwsServiceProviderTest
8+
{
9+
public function setUp()
10+
{
11+
if (!class_exists(Application::class)) {
12+
$this->markTestSkipped();
13+
}
14+
15+
parent::setUp();
16+
}
17+
18+
protected function setupApplication()
19+
{
20+
// Create the application such that the config is loaded.
21+
$app = new Application(sys_get_temp_dir());
22+
$app->instance('config', new Repository());
23+
24+
return $app;
25+
}
26+
}

0 commit comments

Comments
 (0)