Skip to content

Debug container environment variables #11637

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions configuration/environment_variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -788,3 +788,89 @@ configuration::

.. _`SetEnv`: http://httpd.apache.org/docs/current/env.html
.. _`fastcgi_param`: http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param

Debugging Variables
---------------------------

.. versionadded:: 4.3

Environment variables debugging was introduced in Symfony 4.3.

You can find out which environment variables are used by the container using the
console. To show all variables and their values, run:

.. code-block:: terminal

$ php bin/console debug:container --env-vars

---------------- ----------------- ---------------------------------------------
Name Default value Real value
---------------- ----------------- ---------------------------------------------
APP_SECRET n/a "471a62e2d601a8952deb186e44186cb3"
FOO "[1, "2.5", 3]" n/a
BAR null n/a
---------------- ----------------- ---------------------------------------------

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

.. note::
Default values will exist only if they are configured for (see :ref:`config-env-vars`)

If some variables used by the container are not defined, you will see a warning with the list of all the
missing variables.

You can also filter the variables by their name:

.. code-block:: terminal

$ php bin/console debug:container --env-var bar

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

// Displaying detailed environment variable usage matching bar

%env(float:key:1:json:BAR)%
---------------------------

----------------- -----------------
Default value n/a
Real value "[1, "2.5", 3]"
Processed value 2.5
----------------- -----------------

%env(int:key:1:json:BAR)%
-------------------------

----------------- -----------------
Default value n/a
Real value "[1, "2.5", 3]"
Processed value 2
----------------- -----------------

%env(json:BAR)%
---------------

----------------- -----------------
Default value n/a
Real value "[1, "2.5", 3]"
Processed value [
1,
"2.5",
3
]
----------------- -----------------

%env(key:1:json:BAR)%
---------------------

----------------- -----------------
Default value n/a
Real value "[1, "2.5", 3]"
Processed value "2.5"
----------------- -----------------

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

.. note::
The only ouput format supported for these commands is `txt`, using any other one will throw en exception.