{"id":20510788,"url":"https://github.com/battis/lazy-secrets","last_synced_at":"2026-04-21T14:02:47.165Z","repository":{"id":63683924,"uuid":"569869349","full_name":"battis/lazy-secrets","owner":"battis","description":"A (thin) wrapper for google/cloud-secret-manager to reduce boilerplate","archived":false,"fork":false,"pushed_at":"2024-03-13T18:17:53.000Z","size":148,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-04-14T09:03:55.949Z","etag":null,"topics":["google-cloud","secret-manager"],"latest_commit_sha":null,"homepage":"https://battis.github.io/lazy-secrets/","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/battis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-11-23T19:59:10.000Z","updated_at":"2024-04-25T19:34:28.448Z","dependencies_parsed_at":"2024-01-08T14:55:33.625Z","dependency_job_id":"469e5de0-70bc-4b0e-a126-0485c11ae08a","html_url":"https://github.com/battis/lazy-secrets","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/battis%2Flazy-secrets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/battis%2Flazy-secrets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/battis%2Flazy-secrets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/battis%2Flazy-secrets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/battis","download_url":"https://codeload.github.com/battis/lazy-secrets/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242117058,"owners_count":20074431,"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":["google-cloud","secret-manager"],"created_at":"2024-11-15T20:31:13.635Z","updated_at":"2026-04-21T14:02:47.115Z","avatar_url":"https://github.com/battis.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lazy Secrets\n\n[![Latest Version](https://img.shields.io/packagist/v/battis/lazy-secrets.svg)](https://packagist.org/packages/battis/lazy-secrets)\n\nA (thin) wrapper for google/cloud-secret-manager to reduce boilerplate\n\n## Install\n\n```bash\ncomposer require battis/lazy-secrets\n```\n\n## Use\n\n```php\nuse Battis\\LazySecrets\\Secrets;\n\n$data = Secrets::get(\"MY_APP_SECRET\");\n```\n\n## Background\n\nWhile the [Google Cloud Secret Manager](https://cloud.google.com/secret-manager/docs)\nis a fine way to store (and access) app secrets, it also entails a bunch of\nboilerplate code that I don't want to fat finger. So, instead of writing...\n\n```php\nuse Google\\Cloud\\SecretManager\\V1\\SecretManagerServiceClient;\n\n$client = new SecretManagerServiceClient();\n$project = $_ENV[\"GOOGLE_CLOUD_PROJECT\"];\n$key = \"MY_APP_SECRET\";\n$version = \"latest\";\n$secret = $client-\u003eaccessSecretVersion(\n  \"projects/$project/secrets/$key/versions/$version\"\n);\n$data = $secret-\u003egetPayload()-\u003egetData();\n\n// and even (if you're packing a lot into one secret)\n$obj = json_decode($data);\n\n// ...and then using the $data or $obj\n```\n\n...I'd rather just write:\n\n```php\nuse Battis\\LazySecrets\\Secrets;\n\n$data = Secrets::get(\"MY_APP_SECRET\");\n\n// or\nSecrets::init($project, true);\n$obj = Secrets::get(\"MY_APP_SECRET\");\n```\n\nAlternatively, a PSR-16 Simple Cache implementation is also available (for\neasy use with dependency injection):\n\n```php\nuse Battis\\LazySecrets\\Cache;\n\n// assume that the `GOOGLE_CLOUD_PROJECT` environment variable is set\n$secrets = new Cache();\n\n$obj = $secrets-\u003eget(\"MY_APP_SECRET\");\n```\n\nor\n\n```php\n/** src/Example/DependencyConsumer */\n\nnamespace Example;\n\nuse Psr\\SimpleCache\\CacheInterface;\n\nclass DependencyConsumer\n{\n  public function __constructor(CacheInterface $cache)\n  {\n    // ...\n  }\n}\n```\n\n```php\n/** src/app.php */\n\n$container = new DI\\Container([\n  Psr\\SimpleCache\\CacheInterface::class =\u003e DI\\create(\n    \\Battis\\LazySecrets\\Cache::class\n  ),\n]);\n$consumer = $container-\u003eget(DependencyConsumer::class);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbattis%2Flazy-secrets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbattis%2Flazy-secrets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbattis%2Flazy-secrets/lists"}