Configure Aws Sdk With Yii

Hi,

I want to integrate Amazon Web Service PHP SDK(http://docs.aws.amazon.com/aws-sdk-php/guide/latest/installation.html) with Yii. I`ve red several articles but non of them helped me. I installed it using a zip archive. Do you have proper steps of integrating it?

Thanks,

Aruna

Hi,

After spending several hours :( I managed to come up with a solution. Here are the steps.

  1. Place extracted aws folder inside protected/vendor

  2. In your config/main.php

    Yii::setPathOfAlias(‘AwsSDK’,Yii::getPathOfAlias(‘application.vendor.aws.*’)); // Place on top of the page

    ‘application.vendor.aws.*’ // Add this to import section

  3. In your action

    require ‘aws-autoloader.php’;

    $awsConfigPath = Yii::app()->basePath . ‘/config/awsConfig.php’;

    $aws = Aws\Common\Aws::factory($awsConfigPath);

    $s3Client = $aws->get(‘s3’);

Thanks,

Aruna

If you are using the SDK to host your Yii app on AWS, then a simpler way is to use a managed hosting PaaS, like Cloudways PHP hosting platform, to deploy your app. This method is much easier because using this platform, you don’t have to manually setup a server or install the Stack and OS. These packages are preconfigure. You can directly start with deploying your Yii app through Git or SFTP.