PHP implementation of the POSIX-compliant dotenv file format specification.
composer require xdg/dotenvLoading environment variables from a set of dotenv files:
useXdg\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:
useXdg\Dotenv\XdgDotenv;
$env = XdgDotenv::evaluate([
__DIR__ . '/.env',
__DIR__ . '/.env.local',
]);
// $env is an associative array containing the loaded variables.var_dump($env);