Static helper to get environment variables in a Symfony 4+ app, loaded either from .env or .env.local.php

v0.0.1 2019-02-28 21:42 UTC

This package is auto-updated.

Last update: 2024-06-29 04:40:10 UTC


Environment helper for Symfony 4+

Latest Stable Version Build Status Coverage Status License


Add the package to your project :

composer require mesavolt/env

Use Mesavolt\Env::has() to test if an environment variable exists in your app and Mesavolt\Env::get() to retrieve it.

Quick note: By default, Env::get($name) throws an exception when the variable is defined but is empty. Use Env::getSafe($name) to not throw an exception and get the empty value.

APP_SECRET="i can see dead people"

Use it in your project :


use Mesavolt\Env;

$secret = Env::get('APP_SECRET');
$empty = Env::getSafe('EMPTY_VAR');


composer dump-autoload # make sure vendor/autoload.php exists