@@ -58,6 +58,8 @@ protected function configure()
5858 new InputOption ('parameter ' , null , InputOption::VALUE_REQUIRED , 'Displays a specific parameter for an application ' ),
5959 new InputOption ('parameters ' , null , InputOption::VALUE_NONE , 'Displays parameters for an application ' ),
6060 new InputOption ('types ' , null , InputOption::VALUE_NONE , 'Displays types (classes/interfaces) available in the container ' ),
61+ new InputOption ('env-var ' , null , InputOption::VALUE_REQUIRED , 'Displays a specific environment variable used in the container ' ),
62+ new InputOption ('env-vars ' , null , InputOption::VALUE_NONE , 'Displays environment variables used in the container ' ),
6163 new InputOption ('format ' , null , InputOption::VALUE_REQUIRED , 'The output format (txt, xml, json, or md) ' , 'txt ' ),
6264 new InputOption ('raw ' , null , InputOption::VALUE_NONE , 'To output raw description ' ),
6365 ])
@@ -75,6 +77,14 @@ protected function configure()
7577
7678 <info>php %command.full_name% --types</info>
7779
80+ To see environment variables used by the container, use the <info>--env-vars</info> flag:
81+
82+ <info>php %command.full_name% --env-vars</info>
83+
84+ Display a specific environment variable by specifying its name with the <info>--env-var</info> option:
85+
86+ <info>php %command.full_name% --env-var=APP_ENV</info>
87+
7888Use the --tags option to display tagged <comment>public</comment> services grouped by tag:
7989
8090 <info>php %command.full_name% --tags</info>
@@ -116,7 +126,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
116126 $ this ->validateInput ($ input );
117127 $ object = $ this ->getContainerBuilder ();
118128
119- if ($ input ->getOption ('types ' )) {
129+ if ($ input ->getOption ('env-vars ' )) {
130+ $ options = ['env-vars ' => true ];
131+ } elseif ($ envVar = $ input ->getOption ('env-var ' )) {
132+ $ options = ['env-vars ' => true , 'name ' => $ envVar ];
133+ } elseif ($ input ->getOption ('types ' )) {
120134 $ options = [];
121135 $ options ['filter ' ] = [$ this , 'filterToServiceTypes ' ];
122136 } elseif ($ input ->getOption ('parameters ' )) {
@@ -156,7 +170,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
156170 throw $ e ;
157171 }
158172
159- if (!$ input ->getArgument ('name ' ) && !$ input ->getOption ('tag ' ) && !$ input ->getOption ('parameter ' ) && $ input ->isInteractive ()) {
173+ if (!$ input ->getArgument ('name ' ) && !$ input ->getOption ('tag ' ) && !$ input ->getOption ('parameter ' ) && ! $ input -> getOption ( ' env-vars ' ) && ! $ input -> getOption ( ' env-var ' ) && $ input ->isInteractive ()) {
160174 if ($ input ->getOption ('tags ' )) {
161175 $ errorIo ->comment ('To search for a specific tag, re-run this command with a search term. (e.g. <comment>debug:container --tag=form.type</comment>) ' );
162176 } elseif ($ input ->getOption ('parameters ' )) {
@@ -209,12 +223,15 @@ protected function getContainerBuilder()
209223 if (!$ kernel ->isDebug () || !(new ConfigCache ($ kernel ->getContainer ()->getParameter ('debug.container.dump ' ), true ))->isFresh ()) {
210224 $ buildContainer = \Closure::bind (function () { return $ this ->buildContainer (); }, $ kernel , \get_class ($ kernel ));
211225 $ container = $ buildContainer ();
212- $ container ->getCompilerPassConfig ()->setRemovingPasses ([]);
213- $ container ->compile ();
214226 } else {
215227 (new XmlFileLoader ($ container = new ContainerBuilder (), new FileLocator ()))->load ($ kernel ->getContainer ()->getParameter ('debug.container.dump ' ));
228+ $ container ->setParameter ('container.build_hash ' , $ hash = ContainerBuilder::hash (__METHOD__ ));
229+ $ container ->setParameter ('container.build_id ' , hash ('crc32 ' , $ hash .time ()));
216230 }
217231
232+ $ container ->getCompilerPassConfig ()->setRemovingPasses ([]);
233+ $ container ->compile ();
234+
218235 return $ this ->containerBuilder = $ container ;
219236 }
220237
0 commit comments