https://github.com/onesoft-sudo/envoy
A simple environment configuration loader.
https://github.com/onesoft-sudo/envoy
env environment-variables php
Last synced: over 1 year ago
JSON representation
A simple environment configuration loader.
- Host: GitHub
- URL: https://github.com/onesoft-sudo/envoy
- Owner: onesoft-sudo
- License: apache-2.0
- Created: 2021-12-06T14:25:57.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-16T14:19:58.000Z (almost 4 years ago)
- Last Synced: 2025-01-29T22:18:08.647Z (over 1 year ago)
- Topics: env, environment-variables, php
- Language: PHP
- Homepage:
- Size: 72.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
# Envoy
[](https://github.com/onesoft-sudo/envoy/actions/workflows/php.yml)
[](https://packagist.org/packages/osn/envoy)

A simple environment configuration loader.
## Installation
You can install envoy using composer:
```
$ composer require osn/envoy
```
## Usage
Once you've installed envoy, you can include the composer-generated autoloader into your project and start writing code:
```php
load();
print_r($_ENV);
}
catch(\OSN\Envoy\EntityParseErrorException $e){
echo "Error while parsing the file: " . $e->getMessage();
}
```
If the `.env` file is this:
```
DSN=mysql:host=localhost;port=3306;dbname=mydatabase
DB_USER=root
DB_PASSWORD=
```
Then the above code should print:
```
Array (
[DSN] => mysql:host=localhost;port=3306;dbname=mydatabase
[DB_USER] => root
[DB_PASSWORD] =>
)
```
## Configuration
When you create the `Envoy` object, you can pass the config array as second parameter to the constructor. The array follows the follwing structure:
```php
[
\OSN\Envoy\Envoy::CONFIG_OPTION_HERE => "value",
\OSN\Envoy\Envoy::CONFIG_OPTION_2 => true,
]
```
### Available Configuration Options
Option |Values|Description
-----------------------------|------|---------------------------------------------------------------------------------------------
`CONFIG_ASSIGN_ENV_TO_SERVER`|`bool`|Specify that envoy should also push the environment variables to the super global `$_SERVER`.
## Support
Please contact us at [envoy@onesoftnet.eu.org](mailto:envoy@onesoftnet.eu.org).