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 https://getcomposer.org/installer | php
php composer.phar install
You need to set your AWS security credentials before the sample is able to connect to AWS. The SDK will automatically pick up credentials in environment variables:
export AWS_ACCESS_KEY_ID="your-aws-access-key-id"
export AWS_SECRET_KEY="your-aws-secret-access-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.
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.