Table Of Contents


Follow Us

Recent Blog Posts


Installing via Composer

Using Composer is the recommended way to install the AWS SDK for PHP. Composer is a dependency management tool for PHP that allows you to declare the dependencies your project needs and installs them into your project. In order to use the SDK with Composer, you must do the following:

  1. Add "aws/aws-sdk-php" as a dependency in your project's composer.json file.

        "require": {
            "aws/aws-sdk-php": "2.*"

    Consider tightening your dependencies to a known version (e.g., 2.5.*).

  2. Download and install Composer.

    curl -sS | php
  3. Install your dependencies.

    php composer.phar install
  4. Require Composer's autoloader.

    Composer 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

During your development, you can keep up with the latest changes on the master branch by setting the version requirement for the SDK to dev-master.

   "require": {
      "aws/aws-sdk-php": "dev-master"

If you are deploying your application to AWS Elastic Beanstalk, and you have a composer.json file in the root of your package, then Elastic Beanstalk will automatically perform a Composer install when you deploy your application.

Installing via Phar

Each release of the AWS SDK for PHP ships with a pre-packaged phar (PHP archive) file containing all of the classes and dependencies you need to run the SDK. Additionally, the phar file automatically registers a class autoloader for the AWS SDK for PHP and all of its dependencies when included. Bundled with the phar file are the following required and suggested libraries:

You can download the packaged Phar and simply include it in your scripts to get started:

require '/path/to/aws.phar';

If you have phing installed, you can clone the SDK and build a phar file yourself using the "phar" task.


If you are using PHP with the Suhosin patch (especially common on Ubuntu and Debian distributions), you may need to enable the use of phars in the suhosin.ini. Without this, including a phar file in your code will cause it to silently fail. You should modify the suhosin.ini file by adding the line:

suhosin.executor.include.whitelist = phar

Installing via Zip

Each release of the AWS SDK for PHP (since 2.3.2) ships with a zip file containing all of the classes and dependencies you need to run the SDK in a PSR-0 compatible directory structure. Additionally, the zip file includes a class autoloader for the AWS SDK for PHP and the following required and suggested libraries:

Using the zip file is great if you:

  1. Prefer not to or cannot use package managers like Composer and PEAR.
  2. Cannot use phar files due to environment limitations.
  3. Want to use only specific files from the SDK.

To get started, you must download the zip file, unzip it into your project to a location of your choosing, and include the autoloader:

require '/path/to/aws-autoloader.php';

Alternatively, you can write your own autoloader or use an existing one from your project.

If you have phing installed, you can clone the SDK and build a zip file yourself using the "zip" task.

Installing via PEAR

PEAR packages are easy to install, and are available in your PHP environment path so that they are accessible to any PHP project. PEAR packages are not specific to your project, but rather to the machine they're installed on.

From the command-line, you can install the SDK with PEAR as follows (this might need to be run as sudo):

pear config-set auto_discover 1
pear channel-discover
pear install aws/sdk

Alternatively, you can combine all three of the preceding statements into one by doing the following:

pear -D auto_discover=1 install

Once the SDK has been installed via PEAR, you can include the aws.phar into your project with:

require 'AWSSDKforPHP/aws.phar';

This assumes that the PEAR directory is in your PHP include path, which it probably is, if PEAR is working correctly. If needed, you can determine your PEAR directory by running pear config-get php_dir.