Gcp Metadata Php Save

Get the metadata from a Google Cloud Platform environment.

Project README

GCP Metadata

Get the metadata from a Google Cloud Platform environment.

Current version Supported PHP version GitHub license Unit Tests Sponsor

$ composer install kreait/gcp-metadata
use Kreait\GcpMetadata;

$metadata = new GcpMetadata();

Check if the metadata server is available

$isAvailable = $metadata->isAvailable();

Get all available instance properties

$data = $metadata->instance();

Get all available project properties

$data = $metadata->project();

Access a specific property

$data = $metadata->instance('hostname');

Wrap queries in a try/catch block if you don't check for availability

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();
}
Open Source Agenda is not affiliated with "Gcp Metadata Php" Project. README Source: kreait/gcp-metadata-php
Stars
66
Open Issues
0
Last Commit
1 year ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating