Symfony – Debug the value of an environment variable

In Symfony you can define some configuration in the .env file. To be sure of the value the program actually receives at runtime, there is the following command

php bin/console debug:container --env-var=DATABASE_URL --env=test

With this command you can easily see the value Symfony uses

php bin/console debug:container --env-var=DATABASE_URL

Symfony Container Environment Variables
=======================================

 // Displaying detailed environment variable usage matching DATABASE_URL

%env(resolve:DATABASE_URL)%
---------------------------

 ----------------- -----------------------------------------------------------------
  Default value     n/a
  Real value        "%env(resolve:DATABASE_URL_DOCKER)%"
  Processed value   "mysql://root:rooot@db:3306/database"
 ----------------- -----------------------------------------------------------------

 // Note real values might be different between web and CLI.