mesavolt / env
Static helper to get environment variables in a Symfony 4+ app, loaded either from .env or .env.local.php
Installs: 1 302
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=7.1
Requires (Dev)
- phpunit/phpunit: ^7
This package is auto-updated.
Last update: 2024-11-29 05:58:34 UTC
README
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. UseEnv::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