felixdorn/dot-env

This package is abandoned and no longer maintained. The author suggests using the vlucas/phpdotenv package instead.

The most lightweight .env parser for PHP. With concatenation.

1.2.1 2019-08-26 23:06 UTC

This package is auto-updated.

Last update: 2020-05-26 08:17:25 UTC


README

composer require felixdorn/dot-env

Easier than you think !

use Felix\DotEnv;
DotEnv::register('.env');

Note that you could register multiple .env

.env

FOO=BAR # You can access to FOO by typing $_SERVER['FOO'] or $_ENV['FOO'] or getenv('FOO')
NAME=Hello${FOO} #  Will print HelloBar
NICKNAME=Felix
# You can write comment ! Yeah !
SENTENCE="Hey Guys" # space allowed only when value is in parentheses
ANOTHER_SENTENCES="Hey ${NICKNAME}" # will print Hey Felix
baDCase=DUMMY_VALUE # baDCase became BADCASE when parsing so access to baDCase value with $_SERVER['BADCASE']
something # To make workflow more simple, this will output an empty value like $_ENV['SOMETHING']
fdsldjs=${UNEXISTING} # This will be simply removed while this value doesn't exist 

Parse only

if you want to just parse an env file without put values in ENV

$content = (new DotEnv)->setFilename('../tests/.env.test')->parseOnly();