Get the metadata from a Google Cloud Platform environment.
$ composer install kreait/gcp-metadata
use Kreait\GcpMetadata;
$metadata = new GcpMetadata();
$isAvailable = $metadata->isAvailable();
$data = $metadata->instance();
$data = $metadata->project();
$data = $metadata->instance('hostname');
use Kreait\GcpMetadata;
$metadata = new GcpMetadata();
if ($metadata->isAvailable()) {
echo $metadata->instance('hostname');
}
try {
echo $metadata->instance('hostname');
} catch (GcpMetadata\Error $e) {
echo $e->getMessage();
}