我目前正在开发一个 Zend 应用程序,该应用程序将通过一个简单的 Web 界面控制我的 Amazon EC2 实例。
在我到达这里之前我很好:
$ec2 = $this->initEC2()->getEC2();
$instances = $ec2->listInstances();
$this->assign('instances', $instances);
这是我的自定义控制器中的代码Action.php
:
public function initEC2()
{
$key = MW_Config::AWS_ACCESS_KEY;
$secret = MW_Config::AWS_SECRET_KEY;
$region = 'us-east-1';
$infrastructure = Zend_Cloud_Infrastructure_Factory::getAdapter(array(
Zend_Cloud_Infrastructure_Factory::INFRASTRUCTURE_ADAPTER_KEY => 'Zend_Cloud_Infrastructure_Adapter_Ec2',
Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_ACCESS_KEY => $key,
Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_SECRET_KEY => $secret,
Zend_Cloud_Infrastructure_Adapter_Ec2::AWS_REGION => $region,
));
$this->ec2 = $infrastructure;
return $this;
}
public function getEC2()
{
if ($this->ec2 === null) {
$this->initEC2();
}
return $this->ec2;
}
我想知道我如何正确地遍历实例列表以获取视图脚本中的表???
我尝试了 a while()
, afor()
和 aforeach()
但没有任何效果......我浏览了Zend_Cloud_Insfrastructure_InstanceList
(InstanceList.php)的代码,但我没有找到任何结论......