Skip to content
/ dotenv Public

Registers environment variables from a .env file


Notifications You must be signed in to change notification settings


Repository files navigation

Dotenv Component

Symfony Dotenv parses .env files to make environment variables stored in them accessible via $_SERVER or $_ENV.

Getting Started

composer require symfony/dotenv
use Symfony\Component\Dotenv\Dotenv;

$dotenv = new Dotenv();

// you can also load several files
$dotenv->load(__DIR__.'/.env', __DIR__.'/');

// overwrites existing env variables

// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV