Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gree/php-custom-environment-variables
https://github.com/gree/php-custom-environment-variables
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/gree/php-custom-environment-variables
- Owner: gree
- License: mit
- Created: 2019-03-19T07:20:45.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2019-04-11T16:20:13.000Z (over 5 years ago)
- Last Synced: 2024-04-20T23:22:22.261Z (9 months ago)
- Language: PHP
- Size: 30.3 KB
- Stars: 1
- Watchers: 7
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
CustomEnvironmentVariables
----CustomEnvironmentVariables is inspired by [node-config](https://github.com/lorenwest/node-config)'s
[Custom Environment Variables](https://github.com/lorenwest/node-config/wiki/Environment-Variables#custom-environment-variables) feature.[![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)
[![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)## Requirements
PHP 7.1+
## Installation
```bash
$ composer require wfs/custom-environment-variables
```## Usage
Example code `usage.php` is:
```php
[
'name' => 'NAME',
'age' => 'AGE',
]
]);$target = [
'employee' => [
'name' => 'alice',
'age' => '10',
]
];$customized = $customizer->customize($target);
echo("name: {$customized['employee']['name']}" . PHP_EOL);
echo("age: {$customized['employee']['age']}" . PHP_EOL);
```If you does not set any environment variables, `usage.php` result is:
```bash
$ php usage.php
name: alice
age: 10
```If you set `NAME`, `usage.php` result is:
```bash
$ export NAME=bob
$ php usage.php
name: bob
age: 10
```If you set `NAME` and `AGE`, `usage.php` result is:
```bash
$ export NAME=bob
$ export AGE=20
$ php usage.php
name: bob
age: 20
```You will use `CustomEnvironmentVariables` with [Config](https://github.com/hassankhan/config).
Example code `config.php` is:
```php
[
'name' => 'NAME',
'age' => 'AGE',
]
]);$target = new Config(<<customize($target);
echo("name: {$customized['employee']['name']}" . PHP_EOL);
echo("age: {$customized['employee']['age']}" . PHP_EOL);
```result is:
```bash
$ export NAME=bob
$ export AGE=20
$ php config.php
name: alice
age: 10
name: bob
age: 20
```