Skip to content

Commit 3ec4e5f

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

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

configuration/environment_variables.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,3 +788,87 @@ 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 (default and real), 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+
If some variables used by the container are not defined, you will see a warning with the list of all the
817+
missing variables.
818+
819+
You can also filter the variables by their name:
820+
821+
822+
.. code-block:: terminal
823+
824+
$ php bin/console debug:container --env-var bar
825+
826+
Symfony Container Environment Variables
827+
=======================================
828+
829+
// Displaying detailed environment variable usage matching bar
830+
831+
%env(float:key:1:json:BAR)%
832+
---------------------------
833+
834+
----------------- -----------------
835+
Default value n/a
836+
Real value "[1, "2.5", 3]"
837+
Processed value 2.5
838+
----------------- -----------------
839+
840+
%env(int:key:1:json:BAR)%
841+
-------------------------
842+
843+
----------------- -----------------
844+
Default value n/a
845+
Real value "[1, "2.5", 3]"
846+
Processed value 2
847+
----------------- -----------------
848+
849+
%env(json:BAR)%
850+
---------------
851+
852+
----------------- -----------------
853+
Default value n/a
854+
Real value "[1, "2.5", 3]"
855+
Processed value [
856+
1,
857+
"2.5",
858+
3
859+
]
860+
----------------- -----------------
861+
862+
%env(key:1:json:BAR)%
863+
---------------------
864+
865+
----------------- -----------------
866+
Default value n/a
867+
Real value "[1, "2.5", 3]"
868+
Processed value "2.5"
869+
----------------- -----------------
870+
871+
// Note real values might be different between web and CLI.
872+
873+
.. warning::
874+
The only ouput format supported for these commands is `txt`, using any other one will throw en exception.

0 commit comments

Comments
 (0)