Skip to content

Commit dbd4812

Browse files
author
dFayet
committed
Debug container environment variables
1 parent 7d48c4d commit dbd4812

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed

configuration/environment_variables.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,3 +788,89 @@ configuration::
788788

789789
.. _`SetEnv`: http://httpd.apache.org/docs/current/env.html
790790
.. _`fastcgi_param`: http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_param
791+
792+
Debugging Variables
793+
---------------------------
794+
795+
.. versionadded:: 4.3
796+
797+
Environment variables debugging was introduced in Symfony 4.3.
798+
799+
You can find out which environment variables are used by the container using the
800+
console. To show all variables and their values, run:
801+
802+
.. code-block:: terminal
803+
804+
$ php bin/console debug:container --env-vars
805+
806+
---------------- ----------------- ---------------------------------------------
807+
Name Default value Real value
808+
---------------- ----------------- ---------------------------------------------
809+
APP_SECRET n/a "471a62e2d601a8952deb186e44186cb3"
810+
FOO "[1, "2.5", 3]" n/a
811+
BAR null n/a
812+
---------------- ----------------- ---------------------------------------------
813+
814+
// Note real values might be different between web and CLI.
815+
816+
.. note::
817+
Default values will exist only if they are configured for (see :ref:`config-env-vars`)
818+
819+
If some variables used by the container are not defined, you will see a warning with the list of all the
820+
missing variables.
821+
822+
You can also filter the variables by their name:
823+
824+
.. code-block:: terminal
825+
826+
$ php bin/console debug:container --env-var bar
827+
828+
Symfony Container Environment Variables
829+
=======================================
830+
831+
// Displaying detailed environment variable usage matching bar
832+
833+
%env(float:key:1:json:BAR)%
834+
---------------------------
835+
836+
----------------- -----------------
837+
Default value n/a
838+
Real value "[1, "2.5", 3]"
839+
Processed value 2.5
840+
----------------- -----------------
841+
842+
%env(int:key:1:json:BAR)%
843+
-------------------------
844+
845+
----------------- -----------------
846+
Default value n/a
847+
Real value "[1, "2.5", 3]"
848+
Processed value 2
849+
----------------- -----------------
850+
851+
%env(json:BAR)%
852+
---------------
853+
854+
----------------- -----------------
855+
Default value n/a
856+
Real value "[1, "2.5", 3]"
857+
Processed value [
858+
1,
859+
"2.5",
860+
3
861+
]
862+
----------------- -----------------
863+
864+
%env(key:1:json:BAR)%
865+
---------------------
866+
867+
----------------- -----------------
868+
Default value n/a
869+
Real value "[1, "2.5", 3]"
870+
Processed value "2.5"
871+
----------------- -----------------
872+
873+
// Note real values might be different between web and CLI.
874+
875+
.. note::
876+
The only ouput format supported for these commands is `txt`, using any other one will throw en exception.

0 commit comments

Comments
 (0)