简体   繁体   English

如何在Windows平台上加载新的Amazon AWS for PHP?

[英]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.

相关问题 如何在AWS Amazon Linux EC2实例上从PHP 7连接到SQL Server实例? - How to do I connect to a SQL Server instance from PHP 7 on an AWS Amazon Linux EC2 instance? 在本地主机上使用数据库的亚马逊AWS服务器,我如何ssh以便我可以在localhost上运行我的php webservices? - Amazon AWS server with database on localhost, how do I ssh so that my php webservices on localhost can run on it? 如何使用 php hash 在 aws4 中的规范请求以匹配亚马逊 aws sp api 的预期? - How do I hash the canonical request in aws4 using php to match what is expected by amazon aws sp api? 如何使用Heroku作曲家amazon aws sdk上传到亚马逊s3 - How do i upload to amazon s3 using Heroku composer amazon aws sdk 我如何在Windows中启动新的PHP实例而不打开新的CMD窗口? - How do I start a new instance of PHP in Windows without it opening a new CMD window? 什么是“私有 Amazon CloudWatch URL”?AWS SDK for PHP 是否需要 OpenSSL? - What are "private Amazon CloudWatch URLs" & do I need OpenSSL for the AWS SDK for PHP? 如何将新数据加载到div中? - How do I load new data into a div? 使用 AWS 获取您的 Amazon EC2 Windows 密码 PHP SDK - Getting your Amazon EC2 Windows Password with the AWS PHP SDK 如何使用 php 和 Amazon S3 sdk 下载文件? - How do I download a file with php and the Amazon S3 sdk? 如何使PHP文件与Amazon托管一起使用? - How do I make PHP files work with Amazon hosting?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM