Nicolas Grekas 4ee3f13201 Merge branch '7.4' into 8.0
* 7.4:
  [VarDumper] Wrong dumper output for Accept: aplication/json requests
  [HttpKernel] Reset router locale to default when finishing main request
  Only decrement pendingRequests when it's more than zero
  [Dotenv] Fix self-referencing variables with defaults and env key resolution during deferred expansion
  Improve Bulgarian translations in validators.bg.xlf
  [Cache] Fix ChainAdapter ignoring item expiry when propagating to earlier adapters
  [Form] Fix typed property initialization in ValidatorExtension
  [Messenger] Fix duplicate pending messages in Redis transport with batch handlers
  Fix deprecation notices for "@method" annotations when implementing interfaces directly
2026-03-17 15:00:10 +01:00
2026-02-13 13:00:38 +01:00
2025-07-10 10:14:14 +02:00
2026-03-17 15:00:10 +01:00
2017-01-12 08:39:44 -08:00
2025-06-20 12:43:44 +02:00
2025-06-03 14:29:50 +02:00
2026-03-17 14:25:29 +01:00
2023-01-24 15:02:46 +01:00
2025-07-31 11:31:17 +02:00

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

Usage

For an .env file with this format:

YOUR_VARIABLE_NAME=my-string
use Symfony\Component\Dotenv\Dotenv;

$dotenv = new Dotenv();
$dotenv->load(__DIR__.'/.env');

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

// overwrites existing env variables
$dotenv->overload(__DIR__.'/.env');

// loads .env, .env.local, and .env.$APP_ENV.local or .env.$APP_ENV
$dotenv->loadEnv(__DIR__.'/.env');

// Usage with $_ENV
$envVariable = $_ENV['YOUR_VARIABLE_NAME'];

// Usage with $_SERVER
$envVariable = $_SERVER['YOUR_VARIABLE_NAME'];

Resources

Description
⚠️ ARCHIVED: Original GitHub repository no longer exists. Preserved as backup on 2026-01-22T16:32:32.195Z
Readme MIT 770 KiB
Languages
PHP 100%