Skip to content
Sample project to demonstrate usage of the AWS SDK for PHP
Branch: master
Clone or download
Latest commit ae3f39d Jan 25, 2018

AWS SDK for PHP Sample Project

A simple PHP application illustrating usage of the AWS SDK for PHP.


A composer.json file declaring the dependency on the AWS SDK is provided. To install Composer and the SDK, run:

curl -sS | php
php composer.phar install

Basic Configuration

You need to set up your AWS security credentials before the sample code is able to connect to AWS. You can do this by creating a file named "credentials" at ~/.aws/ (C:\Users\USER_NAME\.aws\ for Windows users) and saving the following lines in the file:

aws_access_key_id = <your access key id>
aws_secret_access_key = <your secret key>

See the Security Credentials page for more information on getting your keys. You can also set your credentials in a couple of other ways. See the AWS SDK for PHP documentation for more information.

Running the S3 sample

If you are using IAM security credentials, the user account must have the Full S3 Access policy attached.

This sample application connects to Amazon's Simple Storage Service (S3), creates a bucket, and uploads a file to that bucket. The sample code will generate a bucket name and a file for you, so all you need to do is run the code:

php sample.php

The S3 documentation has a good overview of the restrictions for bucket names for when you start making your own buckets.


This sample application is distributed under the Apache License, Version 2.0.

You can’t perform that action at this time.