razorpay / ec2-metadata
此工具是 PHP 版本的 EC2 实例元数据 API 的重写。
3.0.0
2022-08-26 06:24 UTC
Requires
- php: ^8.1
- mikey179/vfsstream: ^1.6.10
Requires (Dev)
- codacy/coverage: dev-master
- phpunit/phpunit: ^9.5.8
This package is auto-updated.
Last update: 2024-09-14 07:37:41 UTC
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 许可协议。