I'm happy to announce that version 2 of the AWS SDK for PHP is now available. To take advantage of new features in PHP 5.3 and to conform to the recommendations of the PHP Framework Interop Group, we rebuilt the SDK from the ground up. We made these changes to give PHP developers a firm foundation for the future by aligning with a number of other toolkits and projects in the PHP ecosystem that are heading in the same direction.
Highlights
The new SDK is built on top of the Guzzle HTTP client framework, which provides increased performance and enables event-driven customization. Each AWS service client extends the Guzzle client and describes operations on the service using a service description file. The SDK now manages persistent connections for both serial and parallel requests. It detects transient network failures, with automatic retries using truncated exponential backoff. Support for event hooks (via the Symfony2 EventDispatcher) allows you to implement custom, event-driven behavior.
Internally, the SDK now uses a more robust and flexible object-oriented architecture. It makes use of design patterns, event dispatching, and dependency injection. Dependency management and resolution are handled by Composer, simplifying the process of both installing the SDK and auto-loading classes. You can still install the SDK via PEAR or try the downloadable .phar (PHP archive). The Aws\Common namespace contains the core of the SDK; each service client is contained in its own separate namespace (e.g. Aws\DynamoDb).
Goodies
As
you would expect, the SDK provides you with access to AWS services. It
also includes a number of higher-level functions and other goodies to
simplify and streamline your code. For example:
- "Waiter" objects allow you to poll a resource until it exist in the expected state.
- Iterator classes allow you to traverse the results of AWS' list and describe operations. You no longer have to write code to perform multiple requests in a loop or track tokens or markers between calls.
- Requests can be batched for parallel execution.
- Batched writes to Amazon DynamoDB are now supported with a powerful new batch write system.
- Multi-part uploads to Amazon S3 and Amazon Glacier are now supported with a multi-part upload system that can be paused and resumed.
PHP SDK in Action
Let's walk through some code samples so that you can get a taste of the new SDK. You need to load Composer's autoload.php file:
Introduce the AWS namespace:
Then you can create the Aws object, which you can think of as a service builder or dependency injection container:
'key' => 'my-access-key-id',
'secret' => 'my-secret-access-key',
'region' => Region::US_WEST_2
));
Then you get the S3 client from the service builder:
And use it to create a ListObjects Command:
Finally, you create an Iterator and use it to list the contents of the bucket:
foreach ($iterator as $object) {
echo $object['Key'] . ' - ' . $object['Size'] . PHP_EOL;
}
SDK Status
The SDK is available now and supports the following AWS services:
- Amazon S3
- Amazon Glacier
- Amazon DynamoDB
- Amazon CloudFront
We'll continue to broaden support in upcoming releases. Until then, you can install the previous SDK side-by-side with this version by following the directions in our Side-by-Side Guide.
Because of the design and architectural changes, Version 2 of the SDK is not backwards compatible with its predecessor. Our Migration Guide has details on what’s different between the two versions.
SDK Resources
Here are some resources to get you started:
- AWS SDK for PHP 2 Home Page.
- AWS SDK for PHP 2 Getting Started Guide.
- AWS SDK for PHP 2 API Reference.
- AWS SDK for PHP 2 on GitHub.
Go Forth and Code
I hope that you enjoy building awesome AWS apps using the new SDK. Let me know what you think!
-- Jeff;


When will we start to get the apis for other services like Amazon SES, Amazon Simple DB, Amazon Elastic Cache in the new Version 2 of the AWS SDK for PHP.
Posted by: Murugaprabu Marimuthu | November 03, 2012 at 12:03 AM
How long will v1 continue to be updated to support future aws functionality?
Posted by: Steve Morris | November 03, 2012 at 06:23 AM