8000 feature #57829 [FrameworkBundle] Finetune `AboutCommand` (JoppeDC) · devloop42/symfony@6864dbe · GitHub
[go: up one dir, main page]

Skip to content

Commit 6864dbe

Browse files
committed
feature symfony#57829 [FrameworkBundle] Finetune AboutCommand (JoppeDC)
This PR was squashed before being merged into the 7.2 branch. Discussion ---------- [FrameworkBundle] Finetune `AboutCommand` | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | License | MIT - Make the AboutCommand show more details about the XDebug extension (Installed vs Enabled). - Show the same info about the OPcache and APCu extensions Commits ------- 3440aee [FrameworkBundle] Finetune `AboutCommand`
2 parents e2fa11b + 3440aee commit 6864dbe

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
* A console command to display information about the current installation.
2626
*
2727
* @author Roland Franssen <franssen.roland@gmail.com>
28+
* @author Joppe De Cuyper <hello@joppe.dev>
2829
*
2930
* @final
3031
*/
@@ -57,6 +58,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5758
$buildDir = $kernel->getCacheDir();
5859
}
5960

61+
$xdebugMode = getenv('XDEBUG_MODE') ?: \ini_get('xdebug.mode');
62+
6063
$rows = [
6164
['<info>Symfony</>'],
6265
new TableSeparator(),
@@ -81,9 +84,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8184
['Architecture', (\PHP_INT_SIZE * 8).' bits'],
8285
['Intl locale', class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a'],
8386
['Timezone', date_default_timezone_get().' (<comment>'.(new \DateTimeImmutable())->format(\DateTimeInterface::W3C).'</>)'],
84-
['OPcache', \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL) ? 'true' : 'false'],
85-
['APCu', \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL) ? 'true' : 'false'],
86-
['Xdebug', \extension_loaded('xdebug') ? 'true' : 'false'],
87+
['OPcache', \extension_loaded('Zend OPcache') ? (filter_var(\ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed'],
88+
['APCu', \extension_loaded('apcu') ? (filter_var(\ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed'],
89+
['Xdebug', \extension_loaded('xdebug') ? ($xdebugMode && $xdebugMode !== 'off' ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled') : 'Not installed'],
8790
];
8891

8992
$io->table([], $rows);

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,17 @@
258258
<div class="metrics">
259259
<div class="metric-group">
260260
<div class="metric">
261-
<span class="value value-is-icon {{ not collector.haszendopcache ? 'value-shows-no-color' }}">{{ source('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
261+
<span class="value value-is-icon {{ not collector.haszendopcache ? 'value-shows-no-color' }}" title="{{ collector.zendopcachestatus|default('') }}">{{ source('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
262262
<span class="label">OPcache</span>
263263
</div>
264264

265265
<div class="metric">
266-
<span class="value value-is-icon {{ not collector.hasapcu ? 'value-shows-no-color' }}">{{ source('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }}</span>
266+
<span class="value value-is-icon {{ not collector.hasapcu ? 'value-shows-no-color' }}" title="{{ collector.apcustatus|default('') }}">{{ source('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }}</span>
267267
<span class="label">APCu</span>
268268
</div>
269269

270270
<div class="metric">
271-
<span class="value value-is-icon {{ not collector.hasxdebug ? 'value-shows-no-color' }}">{{ source('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }}</span>
271+
<span class="value value-is-icon {{ not collector.hasxdebug ? 'value-shows-no-color' }}" title="{{ collector.xdebugstatus|default('') }}">{{ source('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }}</span>
272272
<span class="label">Xdebug</span>
273273
</div>
274274
</div>

src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
4040
$eom = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_MAINTENANCE);
4141
$eol = \DateTimeImmutable::createFromFormat('d/m/Y', '01/'.Kernel::END_OF_LIFE);
4242

43+
$xdebugMode = getenv('XDEBUG_MODE') ?: \ini_get('xdebug.mode');
44+
4345
$this->data = [
4446
'token' => $response->headers->get('X-Debug-Token'),
4547
'symfony_version' => Kernel::VERSION,
@@ -55,8 +57,11 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
5557
'php_intl_locale' => class_exists(\Locale::class, false) && \Locale::getDefault() ? \Locale::getDefault() : 'n/a',
5658
'php_timezone' => date_default_timezone_get(),
5759
'xdebug_enabled' => \extension_loaded('xdebug'),
60+
'xdebug_status' => \extension_loaded('xdebug') ? ($xdebugMode && $xdebugMode !== 'off' ? 'Enabled (' . $xdebugMode . ')' : 'Not enabled') : 'Not installed',
5861
'apcu_enabled' => \extension_loaded('apcu') && filter_var(\ini_get('apc.enabled'), \FILTER_VALIDATE_BOOL),
62+
'apcu_status' => \extension_loaded('apcu') ? (filter_var(\ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed',
5963
'zend_opcache_enabled' => \extension_loaded('Zend OPcache') && filter_var(\ini_get('opcache.enable'), \FILTER_VALIDATE_BOOL),
64+
'zend_opcache_status' => \extension_loaded('Zend OPcache') ? (filter_var(\ini_get('opcache.enable'), FILTER_VALIDATE_BOOLEAN) ? 'Enabled' : 'Not enabled') : 'Not installed',
6065
'bundles' => [],
6166
'sapi_name' => \PHP_SAPI,
6267
];
@@ -192,6 +197,11 @@ public function hasXdebug(): bool
192197
return $this->data['xdebug_enabled'];
193198
}
194199

200+
public function getXdebugStatus(): string
201+
{
202+
return $this->data['xdebug_status'];
203+
}
204+
195205
/**
196206
* Returns true if the function xdebug_info is available.
197207
*/
@@ -208,6 +218,11 @@ public function hasApcu(): bool
208218
return $this->data['apcu_enabled'];
209219
}
210220

221+
public function getApcuStatus(): string
222+
{
223+
return $this->data['apcu_status'];
224+
}
225+
211226
/**
212227
* Returns true if Zend OPcache is enabled.
213228
*/
@@ -216,6 +231,11 @@ public function hasZendOpcache(): bool
216231
return $this->data['zend_opcache_enabled'];
217232
}
218233

234+
public function getZendOpcacheStatus(): string
235+
{
236+
return $this->data['zend_opcache_status'];
237+
}
238+
219239
public function getBundles(): array|Data
220240
{
221241
return $this->data['bundles'];

0 commit comments

Comments
 (0)
0