Installation guide
1. Add both of the SDKs as dependencies in your project's composer.json file.
{
"require": {
"aws/aws-sdk-php": "*",
"amazonwebservices/aws-sdk-for-php": "*"
}
}
Note: Consider tightening your dependencies to a known version when deploying mission critical applications
(e.g., 2.0.*).
2. Download and install Composer.
curl -s "http://getcomposer.org/installer" | php
3. Install your dependencies.
php composer.phar install
4. Require Composer's autoloader.
Composer also prepares an autoload file that's capable of autoloading all of the classes in any of the libraries
that it downloads. To use it, just add the following line to your code's bootstrap process.
require '/path/to/sdk/vendor/autoload.php';
You can find out more on how to install Composer, configure autoloading, and other best-practices for defining
dependencies at getcomposer.org.
Without Composer
Without Composer, you must manage your own project dependencies.
1. Download both of the SDKs (via PEAR, GitHub, or the AWS website) into a location accessible by your project.
Make certain to use the pre-packaged aws.phar file, which includes all of the dependencies for the AWS
SDK for PHP.
2. In your code's bootstrap process, you need to explicitly require the bootstrap file from Version 1 of the SDK and
the aws.phar file containing Version 2 of the SDK:
// Include each of the SDK's bootstrap files to setup autoloading
require '/path/to/sdk.class.php'; // Load the Version 1 bootstrap file
require '/path/to/aws.phar'; // Load the Version 2 pre-packaged phar file
Configuring and Instantiating the SDKs
How you configure and instantiate the SDKs is determined by whether or not you are using the service builder
(Aws\Common\Aws class).
Instantiating Clients via the Service Builder
The service builder (Aws\Common\Aws class) in the AWS SDK for PHP enables configuring all service clients
with the same credentials. It also accepts additional settings for some or all of the clients. The service builder
functionality is inherited from the Guzzle project.
You can pass the service builder a configuration file containing your credentials and other settings. It will then inject
these into all of the service clients your code instantiates. For more information about the configuration file, please
read the Configuring the SDK section of the guide. When using both SDKs side-by-side, your configuration file must
include the following line:
'includes' => array('_sdk1'),
Side-by-side Guide
16