{"id":18818708,"url":"https://github.com/kreait/gcp-metadata-php","last_synced_at":"2025-04-09T19:18:09.321Z","repository":{"id":50973094,"uuid":"142562035","full_name":"kreait/gcp-metadata-php","owner":"kreait","description":"Get the metadata from a Google Cloud Platform environment.","archived":false,"fork":false,"pushed_at":"2022-06-21T22:21:57.000Z","size":40,"stargazers_count":66,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T19:18:05.471Z","etag":null,"topics":["gce","gcp","google","google-cloud","google-cloud-engine","google-cloud-platform"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kreait.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"jeromegamez"}},"created_at":"2018-07-27T10:12:25.000Z","updated_at":"2023-12-24T21:51:13.000Z","dependencies_parsed_at":"2022-09-11T02:01:44.646Z","dependency_job_id":null,"html_url":"https://github.com/kreait/gcp-metadata-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreait%2Fgcp-metadata-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreait%2Fgcp-metadata-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreait%2Fgcp-metadata-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kreait%2Fgcp-metadata-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kreait","download_url":"https://codeload.github.com/kreait/gcp-metadata-php/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248094989,"owners_count":21046770,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gce","gcp","google","google-cloud","google-cloud-engine","google-cloud-platform"],"created_at":"2024-11-08T00:17:59.780Z","updated_at":"2025-04-09T19:18:09.294Z","avatar_url":"https://github.com/kreait.png","language":"PHP","funding_links":["https://github.com/sponsors/jeromegamez"],"categories":[],"sub_categories":[],"readme":"# GCP Metadata\n\n\u003e Get the metadata from a Google Cloud Platform environment.\n\n[![Current version](https://img.shields.io/packagist/v/kreait/gcp-metadata.svg)](https://packagist.org/packages/kreait/gcp-metadata)\n[![Supported PHP version](https://img.shields.io/packagist/php-v/kreait/gcp-metadata.svg)]()\n[![GitHub license](https://img.shields.io/github/license/kreait/gcp-metadata-php.svg)](https://github.com/kreait/gcp-metadata-php/blob/main/LICENSE)\n[![Unit Tests](https://github.com/kreait/gcp-metadata-php/workflows/Unit%20Tests/badge.svg)](https://github.com/kreait/gcp-metadata-php/actions)\n[![Sponsor](https://img.shields.io/static/v1?logo=GitHub\u0026label=Sponsor\u0026message=%E2%9D%A4\u0026color=ff69b4)](https://github.com/sponsors/jeromegamez)\n\n```bash\n$ composer install kreait/gcp-metadata\n```\n\n```php\nuse Kreait\\GcpMetadata;\n\n$metadata = new GcpMetadata();\n```\n\n#### Check if the metadata server is available\n\n```php\n$isAvailable = $metadata-\u003eisAvailable();\n```\n\n#### Get all available instance properties\n\n```php\n$data = $metadata-\u003einstance();\n```\n\n#### Get all available project properties\n\n```php\n$data = $metadata-\u003eproject();\n```\n\n#### Access a specific property\n\n```php\n$data = $metadata-\u003einstance('hostname');\n```\n\n#### Wrap queries in a try/catch block if you don't check for availability\n\n```php\nuse Kreait\\GcpMetadata;\n\n$metadata = new GcpMetadata();\n\nif ($metadata-\u003eisAvailable()) {\n    echo $metadata-\u003einstance('hostname');\n}\n\ntry {\n    echo $metadata-\u003einstance('hostname');   \n} catch (GcpMetadata\\Error $e) {\n    echo $e-\u003egetMessage();\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkreait%2Fgcp-metadata-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkreait%2Fgcp-metadata-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkreait%2Fgcp-metadata-php/lists"}