Configuring AWS SDK with PHP

AmazonWebservices_Logo.svg
The AWS SDK for PHP can be configured in many ways to suit your needs. This guide highlights the use of configuration files with the service builder as well as individual client configuration options.

The simple way is as follows:

First we need to import AWS SDK  into our project and than we will do following,

require './AWS/aws-autoloader.php';

use Aws\S3\S3Client;
use Aws\Common\Exception\MultipartUploadException;
use Aws\S3\Model\MultipartUpload\UploadBuilder;
use Aws\S3\Exception\S3Exception; 

Now we will simply use below code to get connection with S3 Storage

try {
        $s3Client = S3Client::factory(array(
            'key'    => API_KEY,
            'secret' => API_SECRET
        ));
    } catch (S3Exception $e) {
        echo CONNECT_S3;
    }

For more information you can visit AWS Configuration with PHP

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s