8000 feature #44483 [HttpKernel][WebProfilerBundle] adding xdebug_info pag… · symfony/symfony@94533d4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 94533d4

Browse files
committed
feature #44483 [HttpKernel][WebProfilerBundle] adding xdebug_info page to webprofilerbundle (chr-hertel)
This PR was merged into the 6.1 branch. Discussion ---------- [HttpKernel][WebProfilerBundle] adding xdebug_info page to webprofilerbundle | Q | A | ------------- | --- | Branch? | 6.1 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | n/a | License | MIT | Doc PR | n/a Had a pretty annoying day and thought this should be a thing ... ![Bildschirmfoto von 2021-12-06 21-03-05](https://user-images.githubusercontent.com/2852185/144915336-070cf62e-bd9d-428d-9c1b-5f762c191e19.png) Commits ------- 845f35f adding xdebug_info page to webprofilerbundle
2 parents 25b8bd9 + 845f35f commit 94533d4

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

src/Symfony/Bundle/WebProfilerBundle/Controller/ProfilerController.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,30 @@ public function phpinfoAction(): Response
323323
return new Response($phpinfo, 200, ['Content-Type' => 'text/html']);
324324
}
325325

326+
/**
327+
* Displays the Xdebug info.
328+
*
329+
* @throws NotFoundHttpException
330+
*/
331+
public function xdebugAction(): Response
332+
{
333+
$this->denyAccessIfProfilerDisabled();
334+
335+
if (!\function_exists('xdebug_info')) {
336+
throw new NotFoundHttpException('Xdebug must be installed in version 3.');
337+
}
338+
339+
if (null !== $this->cspHandler) {
340+
$this->cspHandler->disableCsp();
341+
}
342+
343+
ob_start();
344+
xdebug_info();
345+
$xdebugInfo = ob_get_clean();
346+
347+
return new Response($xdebugInfo, 200, ['Content-Type' => 'text/html']);
348+
}
349+
326350
/**
327351
* Displays the source of a file.
328352
*

src/Symfony/Bundle/WebProfilerBundle/Resources/config/routing/profiler.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
<default key="_controller">web_profiler.controller.profiler::phpinfoAction</default>
2121
</route>
2222

23+
<route id="_profiler_xdebug" path="/xdebug">
24+
<default key="_controller">web_profiler.controller.profiler::xdebugAction</default>
25+
</route>
26+
2327
<route id="_profiler_search_results" path="/{token}/search/results">
2428
<default key="_controller">web_profiler.controller.profiler::searchResultsAction</default>
2529
</route>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@
6464

6565
<div class="sf-toolbar-info-piece sf-toolbar-info-php-ext">
6666
<b>PHP Extensions</b>
67-
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.hasxdebug ? 'green' : 'gray' }}">xdebug {{ collector.hasxdebug ? '' : '' }}</span>
67+
{% if collector.hasXdebugInfo %}
68+
<a href="{{ path('_profiler_xdebug') }}" title="View xdebug_info()">
69+
{% endif %}
70+
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.hasXdebug ? 'green' : 'gray' }}">Xdebug {{ collector.hasXdebug ? '' : '' }}</span>
71+
{% if collector.hasXdebugInfo %}
72+
</a>
73+
{% endif %}
6874
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.hasapcu ? 'green' : 'gray' }}">APCu {{ collector.hasapcu ? '' : '' }}</span>
6975
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.haszendopcache ? 'green' : 'red' }}">OPcache {{ collector.haszendopcache ? '' : '' }}</span>
7076
</div>

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ div.sf-toolbar .sf-toolbar-block a:hover {
190190
.sf-toolbar-block .sf-toolbar-info-piece span {
191191
font-size: 12px;
192192
}
193+
div.sf-toolbar .sf-toolbar-block .sf-toolbar-info-piece.sf-toolbar-info-php-ext a {
194+
text-decoration: none;
195+
}
193196

194197
.sf-toolbar-block .sf-toolbar-info {
195198
background-color: #444;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,21 @@ public function isDebug(): bool|string
195195
}
196196

197197
/**
198-
* Returns true if the XDebug is enabled.
198+
* Returns true if the Xdebug is enabled.
199199
*/
200-
public function hasXDebug(): bool
200+
public function hasXdebug(): bool
201201
{
202202
return $this->data['xdebug_enabled'];
203203
}
204204

205+
/**
206+
* Returns true if the function xdebug_info is available.
207+
*/
208+
public function hasXdebugInfo(): bool
209+
{
210+
return \function_exists('xdebug_info');
211+
}
212+
205213
/**
206214
* Returns true if APCu is enabled.
207215
*/

0 commit comments

Comments
 (0)
0