Skip to content

php-xdg/dotenv

Repository files navigation

xdg/dotenv

codecov

PHP implementation of the POSIX-compliant dotenv file format specification.

Installation

composer require xdg/dotenv

Usage

Loading environment variables from a set of dotenv files:

use Xdg\Dotenv\XdgDotenv;

$env = XdgDotenv::load([
    __DIR__ . '/.env',
    __DIR__ . '/.env.local',
]);
// $env is an associative array containing the loaded variables.
var_dump($env);

If you want to evaluate the dotenv files without loading them into the environment, use the following:

use Xdg\Dotenv\XdgDotenv;

$env = XdgDotenv::evaluate([
    __DIR__ . '/.env',
    __DIR__ . '/.env.local',
]);
// $env is an associative array containing the loaded variables.
var_dump($env);

Releases

No releases published

Packages

No packages published

Languages