PHP code example of zodimo / yii-aws-sdk

1. Go to this page and download the library: Download zodimo/yii-aws-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zodimo / yii-aws-sdk example snippets


Yii::setPathOfAlias('zodimo', dirname(__FILE__).'/../../../vendor/zodimo');

'components'=>array(
    //..
    'awsSdk'=>array(
        'class'=>'zodimo.yii-aws-sdk.AwsSdk',
        'sharedConfig'=>array(
            'region'  => 'us-east-2',
            'version' => 'latest',
            'credentials' => array(
                'key' => 'your-aws-key',
                'secret' => 'your-aws-secret',
            ),
        ),
        'serviceConfig'=>array(
            //Service specific config
            'S3'=>array(
                'region'  => 'us-east-2',
                'credentials' => array(
                    'key' => 'your-aws-key',
                    'secret' => 'your-aws-secret',
                ),                        
            ),
        ),                
           
    ),
    //..
)


 $s3Client =yii::app()->awsSdk->createS3();
 //create bucket
 $s3Client->createBucket('BucketExists',['Bucket' => $bucket_name]);
 $s3Client->waitUntil(
     'BucketExists',
     array(
         'Bucket' => $bucket_name,
         '@waiter' => [
             'delay'       => 3,
             'maxAttempts' => 10
         ]
 ));
 $response = $s3Client->listBuckets();
 foreach ($response['Buckets'] as $bucket){
    //Do stuff
 }