Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9011f47

Browse filesBrowse files
committed
[FrameworkBundle] Expose dotenv in bin/console about
1 parent ed57e74 commit 9011f47
Copy full SHA for 9011f47

File tree

2 files changed

+40
-3
lines changed
Filter options

2 files changed

+40
-3
lines changed

‎src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ CHANGELOG
5959
and `YamlLintCommand` classes have been marked as final
6060
* Added `asset.request_context.base_path` and `asset.request_context.secure` parameters
6161
to provide a default request context in case the stack is empty (similar to `router.request_context.*` parameters)
62+
* Display environment variables managed by `Dotenv` in `AboutCommand`
6263

6364
3.3.0
6465
-----

‎src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AboutCommand.php
+39-3Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ class AboutCommand extends ContainerAwareCommand
3535
*/
3636
protected function configure()
3737
{
38-
$this->setDescription('Displays information about the current project');
38+
$this
39+
->setDescription('Displays information about the current project')
40+
->setHelp(<<<'EOT'
41+
The <info>%command.name%</info> command displays information about the current Symfony project.
42+
43+
The <info>PHP</info> section displays important configuration that could affect your application. The values might
44+
be different between web and CLI.
45+
46+
The <info>Environment</info> section displays the current environment variables managed by Symfony Dotenv. It will not
47+
be shown if no variables were found. The values might be different between web and CLI.
48+
EOT
49+
)
50+
;
3951
}
4052

4153
/**
@@ -48,7 +60,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
4860
/** @var $kernel KernelInterface */
4961
$kernel = $this->getApplication()->getKernel();
5062

51-
$io->table(array(), array(
63+
$rows = array(
5264
array('<info>Symfony</>'),
5365
new TableSeparator(),
5466
array('Version', Kernel::VERSION),
@@ -75,7 +87,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
7587
array('OPcache', extension_loaded('Zend OPcache') && ini_get('opcache.enable') ? 'true' : 'false'),
7688
array('APCu', extension_loaded('apcu') && ini_get('apc.enabled') ? 'true' : 'false'),
7789
array('Xdebug', extension_loaded('xdebug') ? 'true' : 'false'),
78-
));
90+
);
91+
92+
if ($dotenv = self::getDotEnvVars()) {
93+
$rows = array_merge($rows, array(
94+
new TableSeparator(),
95+
array('<info>Environment (.env)</>'),
96+
new TableSeparator(),
97+
), array_map(function ($value, $name) {
98+
return array($name, $value);
99+
}, $dotenv, array_keys($dotenv)));
100+
}
101+
102+
$io->table(array(), $rows);
79103
}
80104

81105
private static function formatPath($path, $baseDir = null)
@@ -103,4 +127,16 @@ private static function isExpired($date)
103127

104128
return false !== $date && new \DateTime() > $date->modify('last day of this month 23:59:59');
105129
}
130+
131+
private static function getDotEnvVars()
132+
{
133+
$vars = array();
134+
foreach (explode(',', getenv('SYMFONY_DOTENV_VARS')) as $name) {
135+
if ('' !== $name && false !== $value = getenv($name)) {
136+
$vars[$name] = $value;
137+
}
138+
}
139+
140+
return $vars;
141+
}
106142
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.