PHPackages                             brannow/envyml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. brannow/envyml

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

brannow/envyml
==============

Registers environment variables from a env.yml file

7.4.0(5mo ago)07.7k1MITPHPPHP ^8.2CI passing

Since Oct 13Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/brannow/envyml)[ Packagist](https://packagist.org/packages/brannow/envyml)[ Docs](https://symfony.com)[ RSS](/packages/brannow-envyml/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (8)Dependencies (4)Versions (9)Used By (0)

envyml
======

[](#envyml)

symfony/dotenv adapter to load env.yml file instead

the env file will be cached with the symfony filecache adaper (the modified time of the `env.yml` will be check every request, updates will immediately invalidate the cache)

the yaml syntax will be reformed to match the flat Environment structure. nested element keys will be concated via ' \_ ' (underscore). (numeric lists are KEY\_0, KEY\_1)

for example:

```
Vendor:
  SSO:
    Secret: superSecret
    Provider: stuff
  Captcha:
    secret: otherSecret
    Domain: http://oldDomain

Vendor_Captcha:
  Domain: https://domain
```

will be result in system env:

```
Vendor_SSO_Secret = superSecret
Vendor_SSO_Provider = stuff
Vendor_Captcha_Secret = otherSecret
Vendor_Captcha_Domain = https://domain
```

Installation
------------

[](#installation)

composer: `composer require brannow/envyml`

Post Integration
----------------

[](#post-integration)

Disclamer: all code shown is based on symfony 5.0 (other symfony versions may need updates to run)

it is required to remove the dotenv code snippets from the `index.php` and `bin/console`

```
// ...

// env.yml loader announcement, this will disable dotenv loader
$_SERVER['APP_RUNTIME'] = \Brannow\Component\Envyml\SymfonyRuntime::class;

// set the custom APP_RUNTIME before this line!
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';

// ...
```

update the path to your env.yml location:

```
putenv(ENV_FILE_PATH, 'ABSOLUTE_PATH_HERE')
```

or change in the entrypoint scripts (index.php / console)

```
// env.yml loader announcement, this will disable dotenv loader
$_SERVER['APP_RUNTIME'] = \Brannow\Component\Envyml\SymfonyRuntime::class;
$_ENV['ENV_FILE_PATH'] ??= './env.yml';

// symfony default
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
```

Best Practice
-------------

[](#best-practice)

next update `index.php` and `bin/console`
`index.php`:

```
