A simple and standalone PHP parser for DotEnv files

v1.1.0 2019-09-26 14:19 UTC

This package is auto-updated.

Last update: 2024-02-29 03:44:53 UTC


A simple and standalone DotEnv parser for PHP 5.6+ wich sticks to a unique goal : parse a Dotenv string/file and restitute it as an array of variables.


Full documentation is available at

Quick start

Simply install the library using composer:

composer require bgaze/php-dotenv

Use the Helpers class to parse DotenEnv file or string:

use \Bgaze\Dotenv\Helpers as DotEnv;

try {
    var_dump(DotEnv::fromString('a dotenv string', [ /* some default values */ ]));
    var_dump(DotEnv::fromFile('path/to/dotenv/file', [ /* some default values */ ]));
} catch (\Exception $e) {
    echo "<pre>{$e}</pre>";