How to install the AWS SDK in Yii

 ̄綄美尐妖づ 提交于 2019-12-04 16:03:47

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);

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();

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.

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!