2016-12-27 87 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('').