Skip to content

Commit ebafccd

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

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

configuration/environment_variables.rst

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

0 commit comments

Comments
 (0)