Installation guide

The SDK adopts the PSR standards produced by the PHP Framework Interop Group. An immediately noticeable
change is that all method names are now named using lower camel-case (e.g., putObject instead of
put_object).
Required Regions
The region must be provided to instantiate a client (except in the case where the service has a single endpoint like
Amazon CloudFront). The AWS region you select may affect both your performance and costs.
Client Factories
Factory methods instantiate service clients and do the work of setting up the signature, exponential backoff settings,
exception handler, and so forth. At a minimum you must provide your access key, secret key, and region to the client
factory, but there are many other settings you can use to customize the client behavior.
$dynamodb = Aws\DynamoDb\DynamoDbClient::factory(array(
'key' => 'your-aws-access-key-id',
'secret' => 'your-aws-secret-access-key',
'region' => 'us-west-2',
));
Configuration
A global configuration file can be used to inject credentials into clients automatically via the service builder. The
service builder acts as a dependency injection container for the service clients. (Note: The SDK does not
automatically attempt to load the configuration file like in Version 1 of the SDK.)
$aws = Aws\Common\Aws::factory('/path/to/custom/config.php');
$s3 = $aws->get('s3');
This technique is the preferred way for instantiating service clients. Your config.php might look similar to the
following:
<?php
return array(
'includes' => array('_aws'),
'services' => array(
'default_settings' => array(
'params' => array(
'key' => 'your-aws-access-key-id',
'secret' => 'your-aws-secret-access-key',
'region' => 'us-west-2'
)
)
)
);
The line that says 'includes' => array('_aws') includes the default configuration file packaged with the
SDK. This sets up all of the service clients for you so you can retrieve them by name with the get() method of the
service builder.
Service Operations
Executing operations in the new SDK is similar to how it was in the previous SDK, with two main differences. First,
operations follow the lower camel-case naming convention. Second, a single array parameter is used to pass in all
of the operation options. The following examples show the Amazon S3 PutObject operation performed in each
SDK:
// Previous SDK - PutObject operation
$s3->create_object('bucket-name', 'object-key.txt', array(
'body' => 'lorem ipsum'
));
Migration Guide
10