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

Maintainers

Details

github.com/MesaVolt/env

Source

Issues

Installs: 1 394

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 1

pkg:composer/mesavolt/env

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

This package is auto-updated.

Last update: 2025-09-29 02:09:07 UTC


README

Latest Stable Version Build Status Coverage Status License

Usage

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"
EMPTY_VAR=

Use it in your project :

<?php

use Mesavolt\Env;

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

Testing

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