AWS SDK PHP Class Not Found

雨燕双飞 提交于 2019-12-13 19:11:30

问题


When I am use the AWS SDK with php I get an error stating that the class cannot be found.

    <?php
    require_once  '/var/www/html/aws.phar';
    use Aws\Common\Aws;
    use Aws\Common\Enum\Region;
    echo "test";
    $AWSregion = Region::US_EAST_1;

    $aws = Aws\Common\Aws::factory(array('key'=>'key', 'secret' => 'secret_key', 'region' => $AWSregion));
    $client = $aws->get('Sqs');

?>

The exact error message I receive is PHP Fatal Error: Class 'Aws\Common\Enum\Region' not found in /var/www/html/sendSQS.php

Any help is appreciated.

Thanks!


回答1:


I had same issue with using sdk in wordpress. I installed sdk via composer,but sdk won't work. Please try zip version,and include sdk by "aws-autoloader.php". https://github.com/aws/aws-sdk-php/releases




回答2:


Looks like you are using AWS SDK V2 code with AWS SDK V3. Aws\Common\Enum\Region is obsolete in V3.



来源:https://stackoverflow.com/questions/31654994/aws-sdk-php-class-not-found

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