{"id":19889133,"url":"https://github.com/gree/php-custom-environment-variables","last_synced_at":"2026-05-16T05:02:43.541Z","repository":{"id":57080167,"uuid":"176449406","full_name":"gree/php-custom-environment-variables","owner":"gree","description":null,"archived":false,"fork":false,"pushed_at":"2019-04-11T16:20:13.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-11T19:18:12.191Z","etag":null,"topics":[],"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/gree.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-19T07:20:45.000Z","updated_at":"2020-01-30T13:46:55.000Z","dependencies_parsed_at":"2022-08-24T14:56:57.922Z","dependency_job_id":null,"html_url":"https://github.com/gree/php-custom-environment-variables","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gree%2Fphp-custom-environment-variables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gree%2Fphp-custom-environment-variables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gree%2Fphp-custom-environment-variables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gree%2Fphp-custom-environment-variables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gree","download_url":"https://codeload.github.com/gree/php-custom-environment-variables/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241317601,"owners_count":19943202,"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":[],"created_at":"2024-11-12T18:09:15.309Z","updated_at":"2026-05-16T05:02:43.439Z","avatar_url":"https://github.com/gree.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"CustomEnvironmentVariables\n----\n\nCustomEnvironmentVariables is inspired by [node-config](https://github.com/lorenwest/node-config)'s\n[Custom Environment Variables](https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables) feature.\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/gree/php-custom-environment-variables/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/gree/php-custom-environment-variables/?branch=master)\n[![Code Coverage](https://scrutinizer-ci.com/g/gree/php-custom-environment-variables/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/gree/php-custom-environment-variables/?branch=master)\n\n## Requirements\n\nPHP 7.1+\n\n## Installation\n\n```bash\n$ composer require wfs/custom-environment-variables\n```\n\n## Usage\n\nExample code `usage.php` is:\n\n```php\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Wfs\\CustomEnvironmentVariables\\Customizer;\n\n$customizer = new Customizer([\n    'employee' =\u003e [\n        'name' =\u003e 'NAME',\n        'age' =\u003e 'AGE',\n    ]\n]);\n\n$target = [\n    'employee' =\u003e [\n        'name' =\u003e 'alice',\n        'age' =\u003e '10',\n    ]\n];\n\n$customized = $customizer-\u003ecustomize($target);\n\necho(\"name: {$customized['employee']['name']}\" . PHP_EOL);\necho(\"age: {$customized['employee']['age']}\" . PHP_EOL);\n```\n\nIf you does not set any environment variables, `usage.php` result is:\n\n```bash\n$ php usage.php\nname: alice\nage: 10\n```\n\nIf you set `NAME`, `usage.php` result is:\n\n```bash\n$ export NAME=bob\n$ php usage.php\nname: bob\nage: 10\n```\n\nIf you set `NAME` and `AGE`, `usage.php` result is:\n\n```bash\n$ export NAME=bob\n$ export AGE=20\n$ php usage.php\nname: bob\nage: 20\n```\n\nYou will use `CustomEnvironmentVariables` with [Config](https://github.com/hassankhan/config).\n\nExample code `config.php` is:\n\n```php\n\u003c?php\nrequire __DIR__ . '/vendor/autoload.php';\n\nuse Wfs\\CustomEnvironmentVariables\\Customizer;\nuse Noodlehaus\\Config;\nuse Noodlehaus\\Parser\\Yaml;\n\n$customizer = new Customizer([\n    'employee' =\u003e [\n        'name' =\u003e 'NAME',\n        'age' =\u003e 'AGE',\n    ]\n]);\n\n$target = new Config(\u003c\u003c\u003cCONF\nemployee:\n  name: alice\n  age: '10' # must be string\nCONF\n, new Yaml, true);\n\necho(\"name: {$target['employee']['name']}\" . PHP_EOL);\necho(\"age: {$target['employee']['age']}\" . PHP_EOL);\n\n$customized = $customizer-\u003ecustomize($target);\n\necho(\"name: {$customized['employee']['name']}\" . PHP_EOL);\necho(\"age: {$customized['employee']['age']}\" . PHP_EOL);\n```\n\nresult is:\n\n```bash\n$ export NAME=bob\n$ export AGE=20\n$ php config.php\nname: alice\nage: 10\nname: bob\nage: 20\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgree%2Fphp-custom-environment-variables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgree%2Fphp-custom-environment-variables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgree%2Fphp-custom-environment-variables/lists"}