Install the Amazon SDK for PHP Version 3 - Amazon SDK for PHP
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Install the Amazon SDK for PHP Version 3

You can install the Amazon SDK for PHP Version 3:

  • As a dependency via Composer

  • As a prepackaged phar of the SDK

  • As a ZIP file of the SDK

Before you install Amazon SDK for PHP Version 3 ensure your environment is using PHP version 5.5 or later. Learn more about environment requirements and recommendations.

Note

Installing the SDK via the .phar and .zip methods requires the Multibyte String PHP extension to be installed and enabled separately.

Install Amazon SDK for PHP as a dependency via Composer

Composer is the recommended way to install the Amazon SDK for PHP. Composer is a tool for PHP that manages and installs the dependencies of your project.

For more information on how to install Composer, configure autoloading, and follow other best practices for defining dependencies, see getcomposer.org.

Install Composer

If Composer is not already in your project, download and install Composer on the Download Composer page.

  • For Windows, follow the Windows Installer instructions.

  • For Linux, follow the Command-line installation instructions.

Add Amazon SDK for PHP as a dependency via Composer

If Composer is already installed globally on your system, run the following in the base directory of your project to install Amazon SDK for PHP as a dependency:

$ composer require aws/aws-sdk-php

Otherwise, type this Composer command to install the latest version of the Amazon SDK for PHP as a dependency.

$ php -d memory_limit=-1 composer.phar require aws/aws-sdk-php

Add autoloader to your php scripts

Installing Composer creates several folders and files in your environment. The primary file you will use is autoload.php, which is in the vendor folder in your environment.

To utilize the Amazon SDK for PHP in your scripts, include the autoloader in your scripts, as follows.

<?php require '/path/to/vendor/autoload.php'; ?>

Installing by using the packaged phar

Each release of the Amazon SDK for PHP includes a prepackaged phar (PHP archive) that contains all the classes and dependencies you need to run the SDK. Additionally, the phar automatically registers a class autoloader for the Amazon SDK for PHP and all its dependencies.

You can download the packaged phar and include it in your scripts.

<?php require '/path/to/aws.phar'; ?>
Note

Using PHP with the Suhosin patch is not recommended, but is common on Ubuntu and Debian distributions. In this case, you might need to enable the use of phars in the suhosin.ini. If you don’t do this, including a phar file in your code will cause a silent failure. To modify suhosin.ini, add the following line.

suhosin.executor.include.whitelist = phar

Installing by using the ZIP file

The Amazon SDK for PHP includes a ZIP file containing all the classes and dependencies you need to run the SDK. Additionally, the ZIP file includes a class autoloader for the Amazon SDK for PHP and its dependencies.

To install the SDK, download the .zip file, and then extract it into your project at a location you choose. Then include the autoloader in your scripts, as follows.

<?php require '/path/to/aws-autoloader.php'; ?>