Skip to content

Commit

Permalink
Merge pull request #27 from aws/sdkv3
Browse files Browse the repository at this point in the history
Changes for SDK 3
  • Loading branch information
jeremeamia committed Jun 19, 2015
2 parents 99dfe15 + 70d174f commit 76327d4
Show file tree
Hide file tree
Showing 41 changed files with 650 additions and 1,279 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
language: php

php:
- 5.3
- 5.4
- 5.5
before_script:
- sh -c 'if [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
- cp phpunit.xml.dist phpunit.xml
- composer install --dev
script: vendor/bin/phpunit --coverage-text
- 5.6

sudo: false

install: travis_retry composer install --no-interaction --prefer-source

script: vendor/bin/phpunit
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
CHANGELOG
=========

## 2.0.0

* [BC] PHP minimum version is now 5.5
* [BC] Now require Aws SDK v3
* [BC] To avoid name clashes, module name has been renamed from `Aws` to `AwsModule`.

## 1.2.0

* Added the ability to create protocol-relative URLs with the S3 and CloudFront link view helpers
Expand Down
14 changes: 0 additions & 14 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
<?php
/**
* Copyright 2013 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

namespace Aws;

Expand Down
43 changes: 24 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@ Install the module using Composer into your application's vendor directory. Add
```json
{
"require": {
"aws/aws-sdk-php-zf2": "1.2.*"
"aws/aws-sdk-php-zf2": "2.*"
}
}
```

> If you are using AWS SDK v2, please use the 1.2.* version of the ZF2 module.
## Configuration

Enable the module in your `application.config.php` file.

```php
return array(
'modules' => array(
'Aws'
'AwsModule'
)
);
```
Expand All @@ -41,13 +43,15 @@ the following:
```php
<?php

return array(
'aws' => array(
'key' => '<your-aws-access-key-id>',
'secret' => '<your-aws-secret-access-key>',
return [
'aws' => [
'credentials' => [
'key' => '<your-aws-access-key-id>',
'secret' => '<your-aws-secret-access-key>',
]
'region' => 'us-west-2'
)
);
]
];
```

> NOTE: If you are using [IAM Instance Profile
Expand All @@ -61,10 +65,12 @@ You can get the AWS service builder object from anywhere that the ZF2 service lo
classes). The following example instantiates an Amazon DynamoDB client and creates a table in DynamoDB.

```php
use Aws\Sdk as Aws;

public function indexAction()
{
$aws = $this->getServiceLocator()->get('aws');
$client = $aws->get('dynamodb');
$aws = $this->getServiceLocator()->get(Aws::class);
$client = $aws->create('DynamoDb');

$table = 'posts';

Expand Down Expand Up @@ -92,12 +98,10 @@ public function indexAction()

### View Helpers

Starting from version 1.0.2, the AWS SDK ZF2 Module now provides two view helpers to generate links for Amazon S3 and
Amazon CloudFront resources.
The AWS SDK ZF2 Module now provides two view helpers to generate links for Amazon S3 and Amazon CloudFront resources.

> **Note:** Both of the view helpers generate URLs with an HTTPS scheme by default. This is ideal for security, but
please keep in mind that Amazon CloudFront charges more for HTTPS requests. You can use a different scheme (e.g., HTTP)
by calling the `setScheme` method on either helper.
> **Note:** Starting from v2 of the AWS module, all URLs for both S3 and CloudFront are using HTTPS and this cannot
be modified.

#### S3Link View Helper

Expand Down Expand Up @@ -145,7 +149,7 @@ You can also create signed URLs for private content by passing a third argument

### Filters

Starting from version 1.0.3, the AWS SDK ZF2 module provides a simple file filter that allow to directly upload to S3.
The AWS SDK ZF2 module provides a simple file filter that allow to directly upload to S3.
The `S3RenameUpload` extends `RenameUpload` class, so please refer to [its
documentation](http://framework.zend.com/manual/2.2/en/modules/zend.filter.file.rename-upload.html#zend-filter-file-rename-upload)
for available options.
Expand All @@ -162,11 +166,11 @@ $files = $request->getFiles();
// Fetch the filter from the Filter Plugin Manager to automatically handle dependencies
$filter = $serviceLocator->get('FilterManager')->get('S3RenameUpload');

$filter->setOptions(array(
$filter->setOptions(’[
'bucket' => 'my-bucket',
'target' => 'users/5/profile-picture.jpg',
'overwrite' => true
));
]);

$filter->filter($files['my-upload']);

Expand All @@ -186,11 +190,12 @@ To follow the [ZF2 examples]
the DynamoDB session save handler might be used like this:

```php
use AwsModule\Session\SaveHandler\DynamoDb as DynamoDbSaveHandler;
use Zend\Session\SessionManager;

// Assume we are in a context where $serviceLocator is a ZF2 service locator.

$saveHandler = $serviceLocator->get('Aws\Session\SaveHandler\DynamoDb');
$saveHandler = $serviceLocator->get(DynamoDbSaveHandler::class);

$manager = new SessionManager();
$manager->setSaveHandler($saveHandler);
Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,31 @@
"description": "Zend Framework 2 Module that allows easy integration the AWS SDK for PHP",
"type": "library",
"license": "Apache",
"keywords": ["aws", "zf2", "amazon", "zend", "s3", "dynamodb", "ec2", "cloudfront"],
"keywords": ["aws", "zf2", "amazon", "zend", "s3", "dynamodb", "ec2", "cloudfront", "sqs"],
"require": {
"php": ">=5.3.3",
"aws/aws-sdk-php": "2.*",
"php": ">=5.5",
"aws/aws-sdk-php": "3.*",
"zendframework/zend-filter": "2.*",
"zendframework/zend-servicemanager": "2.*",
"zendframework/zend-session": "2.*",
"zendframework/zend-version": "2.*",
"zendframework/zend-view": "2.*"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpunit/phpunit": "4.*",
"zendframework/zend-modulemanager": "2.*"
},
"autoload": {
"psr-0": {
"Aws\\": "src/"
"psr-4": {
"AwsModule\\": "src/"
},
"classmap": [
"./Module.php"
]
},
"autoload-dev": {
"psr-4": {
"AwsModule\\Tests\\": "tests/"
}
}
}
31 changes: 18 additions & 13 deletions config/aws.local.php.dist
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<?php

return array(
return [
/**
* You can define global configuration settings for the SDK as an array. Typically, you will want to a provide your
* credentials (key and secret key) and the region (e.g. us-west-2) in which you would like to use your services.
* You can also override the setting on a per service basic.
*
* To avoid breaking in your code when updating the SDK, we always recommend you to manually select a version for
* each service instead of relying on the 'latest' keyword
*/
// 'aws' => array(
// 'key' => 'change_me',
// 'secret' => 'change_me',
// 'region' => 'change_me'
// )

/**
* You can alternatively provide a path to an AWS SDK for PHP config file containing your configuration settings.
* Config files can allow you to have finer-grained control over the configuration settings for each service client.
*/
// 'aws' => 'path/to/your/aws-config.php'
);
// 'aws' => [
// 'credentials' => [
// 'key' => 'change_me',
// 'secret' => 'change_me'
// ]
// 'region' => 'change_me',
// 'version' => 'latest',
// 'DynamoDb' => [
// 'region' => 'another_region',
// 'version' => 'latest'
// ]
// ]
];
31 changes: 11 additions & 20 deletions config/aws_zf2.local.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@
* the .dist extension). Change it however you need for your project.
*/

return array(
'aws_zf2' => array(
'session' => array(
'save_handler' => array(
'dynamodb' => array(
return [
'aws_zf2' => [
'session' => [
'save_handler' => [
'dynamodb' => [
// Locking strategy used for doing session locking.
// 'locking_strategy' => null,

// DynamoDb client object used for performing DynamoDB
// operations.
//
// Note: you most likely want to leave this alone and allow
// the factory to fetch your configured instance of
// DynamoDB. However, if you override it with an object, we
// will respect that choice.
// 'dynamodb_client' => null,
// 'locking' => null,

// Name of the DynamoDB table in which to store the
// sessions.
Expand Down Expand Up @@ -63,8 +54,8 @@ return array(

// Maximum time (in microseconds) to wait between attempts to acquire a lock
// 'max_lock_retry_microtime' => 50000,
)
)
)
)
);
]
]
]
]
];
63 changes: 37 additions & 26 deletions config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
<?php

return array(
'service_manager' => array(
'factories' => array(
'Aws' => 'Aws\Factory\AwsFactory',
'Aws\Session\SaveHandler\DynamoDb' => 'Aws\Factory\DynamoDbSessionSaveHandlerFactory'
)
),
use AwsModule\Factory\AwsFactory;
use AwsModule\Factory\CloudFrontLinkViewHelperFactory;
use AwsModule\Factory\DynamoDbSessionSaveHandlerFactory;
use AwsModule\Factory\S3LinkViewHelperFactory;
use AwsModule\Factory\S3RenameUploadFactory;
use AwsModule\Filter\File\S3RenameUpload;
use Aws\Sdk as Aws;
use AwsModule\Session\SaveHandler\DynamoDb as DynamoDbSaveHandler;
use AwsModule\View\Helper\CloudFrontLink;
use AwsModule\View\Helper\S3Link;

'filters' => array(
'factories' => array(
'Aws\Filter\File\S3RenameUpload' => 'Aws\Factory\S3RenameUploadFactory'
),
'aliases' => array(
's3renameupload' => 'Aws\Filter\File\S3RenameUpload'
)
),
return [
'service_manager' => [
'factories' => [
Aws::class => AwsFactory::class,
DynamoDbSaveHandler::class => DynamoDbSessionSaveHandlerFactory::class
]
],

'view_helpers' => array(
'factories' => array(
'Aws\View\Helper\S3Link' => 'Aws\Factory\S3LinkViewHelperFactory',
'Aws\View\Helper\CloudFrontLink' => 'Aws\Factory\CloudFrontLinkViewHelperFactory'
),
'filters' => [
'factories' => [
S3RenameUpload::class => S3RenameUploadFactory::class
],
'aliases' => [
's3renameupload' => S3RenameUpload::class
]
],

'aliases' => array(
'cloudfrontlink' => 'Aws\View\Helper\CloudFrontLink',
's3link' => 'Aws\View\Helper\S3Link'
)
),
);
'view_helpers' => [
'factories' => [
S3Link::class => S3LinkViewHelperFactory::class,
CloudFrontLink::class => CloudFrontLinkViewHelperFactory::class
],

'aliases' => [
'cloudfrontlink' => CloudFrontLink::class,
's3link' => S3Link::class
]
],
];
Loading

0 comments on commit 76327d4

Please sign in to comment.