2016-12-27 58 views
0

我想用下面的代码实例化亚马逊AWS SDK PHP:困难初始化亚马逊AWS PHP SDK - 类AWS COMMON AWS没有找到

require("../aws/aws-autoloader.php"); 

use Aws\S3\S3Client; 
use Aws\Common\Aws; 


// Instantiate the client. 

$aws = Aws::factory('awsConfig.php'); 
$s3Client = $aws->get('s3'); 

我可是被退回以下错误:

Uncaught Error: Class 'Aws\Common\Aws' not found

aws-autoloader文件没有从源代码修改,所以不完全确定它为什么没有找到类?

回答

1

您正在使用适用于PHP v3的AWS开发工具包,同时尝试为适用于PHP v2的AWS开发工具包执行代码。您应该使用Aws\Sdk而不是Aws\Common\Aws

AWS提供了一种迁移指南突出版本2和版本3之间的差异:

From Version 3 of the SDK

Key differences:

Use the Aws\Sdk class instead of Aws\Common\Aws.

No configuration file. Use an array for configuration instead.

The 'version' option is required during instantiation.

Use the create() methods instead of get('').