![Gitter](https://badges.gitter.im/Join Chat.svg)
The AWS SDK for PHP enables PHP developers to use Amazon Web Services in their PHP code, and build robust applications and software using services like Amazon S3, Amazon DynamoDB, Amazon Glacier, etc. You can get started in minutes by installing the SDK through Composer or by downloading a single zip or phar file from our latest release.
S3 support for Signature V2 is being deprecated,
after which only Signature V4 will be supported. Users of V2 of the PHP SDK will
have to upgrade to version 2.5 or later in order to continue using S3. It is
recommended to upgrade to version 3 of the SDK, which uses Signature V4
as a default, if possible. To use Signature V4 with version 2.5+ of the SDK, you
can specify signature
as a configuration option, as in the following example.
$client = S3Client::factory([
'region' => 'us-east-2',
'version' => 'latest',
'signature' => 'v4'
]);
- User Guide – For in-depth getting started and usage information
- API Docs – For operations, parameters, responses, and examples
- Blog – Tips & tricks, articles, and announcements
- Sample Project - A quick, sample project to help get you started
- Forum – Ask questions, get help, and give feedback
- Issues – Report issues and submit pull requests (see Apache 2.0 License)
- @awsforphp – Follow us on Twitter
- Building Apps with Version 3 of the AWS SDK for PHP video from AWS re:Invent 2014
- Provides easy-to-use HTTP clients for all supported AWS services, regions, and authentication protocols.
- Is built for PHP 5.3.3+ and is compliant with PSR-0, PSR-1, and PSR-2.
- Is easy to install through Composer, or by downloading the phar or zip file of our latest release.
- Is built on Guzzle v3, and utilizes many of its features, including persistent connections, parallel requests, events and plugins (via Symfony2 EventDispatcher), service descriptions, over-the-wire logging, caching, flexible batching, and request retrying with truncated exponential backoff.
- Provides convenience features including easy response pagination via Iterators, resource Waiters, and simple modelled responses.
- Allows you to sync local directories to Amazon S3 buckets.
- Provides a multipart uploader tool for Amazon S3 and Amazon Glacier that can be paused and resumed.
- Provides an Amazon S3 Stream Wrapper, so that you can use PHP's native file handling functions to interact with your S3 buckets and objects like a local filesystem.
- Provides the Amazon DynamoDB Session Handler for easily scaling sessions on a fast, NoSQL database.
- Automatically uses IAM Instance Profile Credentials on configured Amazon EC2 instances.
- Sign up for AWS – Before you begin, you need to sign up for an AWS account and retrieve your AWS credentials.
- Minimum requirements – To run the SDK, your system will need to meet the minimum requirements, including having PHP 5.3.3+ compiled with the cURL extension and cURL 7.16.2+ compiled with OpenSSL and zlib.
- Install the SDK – Using Composer is the recommended way to install the
AWS SDK for PHP. The SDK is available via Packagist under the
aws/aws-sdk-php
package. Please see the Installation section of the User Guide for more detailed information about installing the SDK through Composer and other means. - Using the SDK – The best way to become familiar with how to use the SDK is to read the User Guide. The Getting Started Guide will help you become familiar with the basic concepts, and there are also specific guides for each of the supported services.
<?php
require 'vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// Instantiate an S3 client
$s3 = S3Client::factory();
// Upload a publicly accessible file. The file size, file type, and MD5 hash
// are automatically calculated by the SDK.
try {
$s3->putObject(array(
'Bucket' => 'my-bucket',
'Key' => 'my-object',
'Body' => fopen('/path/to/file', 'r'),
'ACL' => 'public-read',
));
} catch (S3Exception $e) {
echo "There was an error uploading the file.\n";
}
You can also use the even easier upload()
method, which will automatically do
either single or multipart uploads, as needed.
try {
$resource = fopen('/path/to/file', 'r');
$s3->upload('my-bucket', 'my-object', $resource, 'public-read');
} catch (S3Exception $e) {
echo "There was an error uploading the file.\n";
}
- Get an object from Amazon S3 and save it to a file
- Upload a large file to Amazon S3 in parts
- Put an item in your Amazon DynamoDB table
- Send a message to your Amazon SQS queue
- Please browse the User Guide and API docs or check out our AWS SDK Development Blog for even more examples and tutorials.
- AWS Service Provider for Laravel
- AWS SDK ZF2 Module
- AWS Service Provider for Silex
- Guzzle v3 – PHP HTTP client and framework
- Other AWS SDKs & Tools (e.g., js, cli, ruby, python, java, etc.)