[英]How do I load the new Amazon AWS for PHP on a Windows platform?
I had been using the PHP library up to version 1.6.2 for Amazon AWS. 我一直在为Amazon AWS使用1.6.2之前的PHP库。 It was great and just worked. 太好了,只是工作了。 Then they rebuilt it and brought out Version 2. 然后他们对其进行了重建,并推出了版本2。
I just want install the latest version without any programs like Composer and others... I have the ZIP file downloaded and copied to a folder http://localhost/aws/
我只想安装最新版本,而不安装Composer等其他程序...我已下载ZIP文件并将其复制到文件夹http://localhost/aws/
How do I access the files and use them? 如何访问文件并使用它们? I have tried numerous examples and nothing works. 我尝试了无数示例,但没有任何效果。 I would prefer to use the latest version and not go back to the old version which is over a year old. 我希望使用最新版本,而不要回到已经使用一年多的旧版本。
I created the following file in the root of the aws folder: 我在aws文件夹的根目录中创建了以下文件:
<?php
$config = array();
$config['key'] = 'MYPUBLICKEY';
$config['secret'] = 'MY SECRET KEY';
$config['region'] = 'us-east-1';
$ec2Client = \aws\Ec2\Ec2Client::factory($config);
$result = $ec2Client->DescribeInstances();
echo "Number of running instances: " . countInstances($result);
?>
I don't get a result. 我没有结果。 It seems to stop at the line $ec2Client =... What should the directory structure be? 它似乎停止在$ ec2Client = ...行。目录结构应该是什么?
The documentation for the AWS SDK for PHP is fairly comprehensive, especially for basic usage. 适用于PHP的AWS开发工具包的文档非常全面,尤其是基本用法。 I would start with the Getting Started Guide , which should provide the information you need. 我将从“ 入门指南”开始,该指南应提供您所需的信息。 With regards to your particular example, you need to correct a few things: 关于您的特定示例,您需要纠正一些问题:
<?php
// Require the autoloader, which is included in the zip
require '/path/to/aws-autoloader.php';
$config = array();
$config['key'] = 'MYPUBLICKEY';
$config['secret'] = 'MY SECRET KEY';
$config['region'] = 'us-east-1';
// Please consider using a credential file instead of hard-coding credentials
// See http://docs.aws.amazon.com/aws-sdk-php/guide/latest/credentials.html#credential-profiles
// Note: Classes and Namespaces are case-sensitive with the autoloader
// (i.e., "Aws", instead of "aws")
$ec2Client = \Aws\Ec2\Ec2Client::factory($config);
$result = $ec2Client->describeInstances();
// SDKv2 has a cool getPath function which makes it easy to traverse results
$instanceCount = count($result->getPath('Reservations/*/Instances');
echo "Number of running instances: " . $instanceCount
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.