Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitf82dbf9

Browse files
[FrameworkBundle] [Console] Added resolve-env option to debug:config command
This option replaces environment variables placeholders by their actual value in the command output
1 parentbb1e1e5 commitf82dbf9

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ CHANGELOG
1919
* Add`KernelTestCase::getContainer()` as the best way to get a container in tests
2020
* Rename the container parameter`profiler_listener.only_master_requests` to`profiler_listener.only_main_requests`
2121
* Add service`fragment.uri_generator` to generate the URI of a fragment
22+
* Add`--resolve-env` option to`debug:config` command to resolve the value of environment variables in the command output
2223

2324
5.2.0
2425
-----

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
useSymfony\Component\Console\Exception\LogicException;
1616
useSymfony\Component\Console\Input\InputArgument;
1717
useSymfony\Component\Console\Input\InputInterface;
18+
useSymfony\Component\Console\Input\InputOption;
1819
useSymfony\Component\Console\Output\OutputInterface;
1920
useSymfony\Component\Console\Style\SymfonyStyle;
2021
useSymfony\Component\DependencyInjection\Compiler\ValidateEnvPlaceholdersPass;
@@ -44,6 +45,7 @@ protected function configure()
4445
->setDefinition([
4546
newInputArgument('name', InputArgument::OPTIONAL,'The bundle name or the extension alias'),
4647
newInputArgument('path', InputArgument::OPTIONAL,'The configuration option path'),
48+
newInputOption('resolve-env',null, InputOption::VALUE_NONE,'Resolve the value of environment variables'),
4749
])
4850
->setDescription(self::$defaultDescription)
4951
->setHelp(<<<'EOF'
@@ -107,6 +109,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
107109

108110
$config =$container->resolveEnvPlaceholders($extensionConfig[$extensionAlias]);
109111

112+
if ($input->getOption('resolve-env')) {
113+
array_walk_recursive($config,function (&$value) {
114+
preg_match_all('{%env\(((?:\w++:)*+\w++)\)%}',$value,$envVars);
115+
$name =current($envVars[1]);
116+
117+
$value =false ===$name ?:$_ENV[$name] ??$_SERVER[$name] ??getenv($name);
118+
});
119+
}
120+
110121
if (null ===$path =$input->getArgument('path')) {
111122
$io->title(
112123
sprintf('Current configuration for %s', ($name ===$extensionAlias ?sprintf('extension with alias "%s"',$extensionAlias) :sprintf('"%s"',$name)))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp