PHP code example of d9magai / ec2-metadata-getter
1. Go to this page and download the library: Download d9magai/ec2-metadata-getter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
d9magai / ec2-metadata-getter example snippets
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