d9magai / ec2-metadata-getter
这个工具是对PHP的EC2实例元数据API的重写。
1.1.3
2014-08-27 09:50 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- mikey179/vfsstream: 1.3.*
- phpunit/phpunit: 3.7.*
README
这个工具是对 EC2实例元数据API 的PHP重写。
这是一个基于 d9magai/Ec2MetadataGetter 的分支。
与分支的差异包括
- 一个名为
getMultiple的额外方法,该方法可以从数组中获取多个实例属性 - 缓存支持。在相同机器上对同一请求重复两次将给出缓存响应。
- 自定义缓存目录。构造函数现在接受一个缓存存储目录并使用它。
- 支持返回模拟数据
使用方法
在composer.json中
"require": { "razorpay/ec2-metadata": "dev-master" }
在您的代码中
<?php use Razorpay\EC2Metadata\Ec2MetadataGetter; $client = new Ec2MetadataGetter($cache_dir); $client->getNetwork(); // Will return network info // You can also enable use in dev environments with the following call: $client->allowDummy(); $client->getAmiId(); // Will always return "ami-12345678" // Another extra feature from the upstream is the inclusion of a getMultiple method: // Dummy is always given priority $client->getMultiple(['Network', ['AmiId']]); // This returns both Network and AmiId in a properly keyed array ?>
许可证
此代码基于MIT许可证。