Nathan H
Nathan H

Reputation: 49371

How to install the AWS SDK in Yii

I would like to use the Amazon AWS SDK for PHP in my Yii project, however I get all kinds of include errors (such as include(CFCredentials.php): failed to open stream: No such file or directory ).

I think it may be related to Yii's assumption that class names must match file names...

What can we do??

Upvotes: 4

Views: 2264

Answers (4)

et071385
et071385

Reputation: 103

In case someone stumbles upon this issue, I've found that if one is using the PHAR file directly (poor decision, I know) and importing via require_once, you cannot call spl_autoload_register to re-add YiiBase autoload until after your SDK call is complete.

At least this was our case when using the StsClient to call assume role with an IAM role.

Upvotes: 1

Jasper
Jasper

Reputation: 389

This is more easier way, You can use Yii S3 Upload extension.

http://www.yiiframework.com/extension/s3upload/

Upvotes: 0

user2107954
user2107954

Reputation: 21

This worked beautifully:

// Include the SDK

Yii::import('application.vendors.aws.*');
spl_autoload_unregister(array('YiiBase', 'autoload'));
require_once 'sdk.class.php';
spl_autoload_register(array('YiiBase', 'autoload'));

// Instantiate the AmazonEC2 class
$ec2 = new AmazonEC2();

Upvotes: 2

Sergey
Sergey

Reputation: 5207

I've made that:

spl_autoload_unregister(array('YiiBase', 'autoload'));
require_once PATH_TO_AWS_SDK . 'sdk.class.php';
// I write down in PATH_TO_AWS_SDK.'config.inc.php' my CFCredentials
spl_autoload_register(array('YiiBase', 'autoload'));

$amazon_opts = array(
    'curlopts' => array(
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_FORBID_REUSE   => false,
    ),
);
$amazon = new AmazonSES();
$response = $amazon->get_send_quota($amazon_opts);

Upvotes: 5

Related Questions