<?php
ini_set('include_path', '/AmazonPHP2/aws/aws-autoloader.php');
use Aws\Common\Aws;
use Aws\Ec2\Exception\Ec2Exception;
#ini_set('include_path', '/aws/aws-autoloader.php');
#ini_set('include_path', '/aws/Aws/Common/Aws');
#ini_set('include_path', '/aws/Aws/Ec2/Exception/Ec2Exception');
$aws = Aws::factory('/aws/Credentials.php');
$ec2Client = $aws->get('Ec2');
try
{
//Create the key pair
$keyPairName = 'my-keypair';
$result = $ec2Client->createKeyPair(array(
'KeyName' => $keyPairName));
print "<b>---- Key Successfully Created ---- <b> " . PHP_EOL;
}
catch (Ec2Exception $e)
{
print "<b>---- Key cannot be generated ---- <b> " . PHP_EOL;
}
当我执行此代码时,我收到以下错误:
Fatal error: Class 'Aws\Common\Aws' not found in /opt/lampp/htdocs/AmazonPOC/Key.php on line 8
AmazonPHP2 包含一个文件夹 aws ,其中包含要使用的类,但在这里它给了我致命错误,但是,代码在 Windows 中运行良好。
谢谢