An open API service indexing awesome lists of open source software.

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.

Awesome Lists containing this project

README

          

# Envoy
[![PHP Composer](https://github.com/onesoft-sudo/envoy/actions/workflows/php.yml/badge.svg)](https://github.com/onesoft-sudo/envoy/actions/workflows/php.yml)
[![Packagist Version](https://img.shields.io/packagist/v/osn/envoy?label=Packagist)](https://packagist.org/packages/osn/envoy)
![](https://img.shields.io/packagist/dt/osn/envoy?label=Downloads)

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).