Skip to content

Commit f437d85

Browse files
committed
feature symfony#20697 Updated the "PHP config" panel in the profiler (javiereguiluz)
This PR was squashed before being merged into the 3.3-dev branch (closes symfony#20697). Discussion ---------- Updated the "PHP config" panel in the profiler | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - I propose to update this panel taking some of the ideas introduced by @ro0NL in symfony#20126: * Adding more info that helps debugging problems (like 32/64 bits, the locale and the timezone) * Removing anything related to PHP acceleration that is not OPcache or APC ### Before ![php-config-before](https://cloud.githubusercontent.com/assets/73419/20751739/b557ca9a-b6fd-11e6-98c4-49e80b16d424.png) ### After ![php-config-after](https://cloud.githubusercontent.com/assets/73419/20751740/b7da5c38-b6fd-11e6-8619-3d3b5f477887.png) Commits ------- 531053b Updated the "PHP config" panel in the profiler
2 parents 814177d + 531053b commit f437d85

File tree

3 files changed

+52
-84
lines changed

3 files changed

+52
-84
lines changed

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -217,35 +217,35 @@
217217
</div>
218218

219219
<div class="metric">
220-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasaccelerator ? 'yes' : 'no') ~ '.svg') }}</span>
221-
<span class="label">PHP acceleration</span>
220+
<span class="value">{{ collector.phparchitecture }} <span class="unit">bits</span></span>
221+
<span class="label">Architecture</span>
222222
</div>
223223

224224
<div class="metric">
225-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }}</span>
226-
<span class="label">Xdebug</span>
225+
<span class="value">{{ collector.phpintllocale }}</span>
226+
<span class="label">Intl locale</span>
227227
</div>
228-
</div>
229228

230-
<div class="metrics metrics-horizontal">
231229
<div class="metric">
232-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
233-
<span class="label">OPcache</span>
230+
<span class="value">{{ collector.phptimezone }}</span>
231+
<span class="label">Timezone</span>
234232
</div>
233+
</div>
235234

235+
<div class="metrics">
236236
<div class="metric">
237-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasapc ? 'yes' : 'no') ~ '.svg') }}</span>
238-
<span class="label">APC</span>
237+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
238+
<span class="label">OPcache</span>
239239
</div>
240240

241241
<div class="metric">
242-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxcache ? 'yes' : 'no') ~ '.svg') }}</span>
243-
<span class="label">XCache</span>
242+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }}</span>
243+
<span class="label">APCu</span>
244244
</div>
245245

246246
<div class="metric">
247-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haseaccelerator ? 'yes' : 'no') ~ '.svg') }}</span>
248-
<span class="label">EAccelerator</span>
247+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }}</span>
248+
<span class="label">Xdebug</span>
249249
</div>
250250
</div>
251251

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

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public function collect(Request $request, Response $response, \Exception $except
6767
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
6868
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
6969
'php_version' => PHP_VERSION,
70+
'php_architecture' => PHP_INT_SIZE * 8,
71+
'php_intl_locale' => \Locale::getDefault() ?: 'n/a',
72+
'php_timezone' => date_default_timezone_get(),
7073
'xdebug_enabled' => extension_loaded('xdebug'),
71-
'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
72-
'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'),
73-
'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'),
74-
'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'),
74+
'apcu_enabled' => extension_loaded('apcu') && ini_get('apc.enabled'),
7575
'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
7676
'bundles' => array(),
7777
'sapi_name' => PHP_SAPI,
@@ -174,6 +174,30 @@ public function getPhpVersion()
174174
return $this->data['php_version'];
175175
}
176176

177+
/**
178+
* @return int The PHP architecture as number of bits (e.g. 32 or 64)
179+
*/
180+
public function getPhpArchitecture()
181+
{
182+
return $this->data['php_architecture'];
183+
}
184+
185+
/**
186+
* @return string
187+
*/
188+
public function getPhpIntlLocale()
189+
{
190+
return $this->data['php_intl_locale'];
191+
}
192+
193+
/**
194+
* @return string
195+
*/
196+
public function getPhpTimezone()
197+
{
198+
return $this->data['php_timezone'];
199+
}
200+
177201
/**
178202
* Gets the application name.
179203
*
@@ -215,23 +239,13 @@ public function hasXDebug()
215239
}
216240

217241
/**
218-
* Returns true if EAccelerator is enabled.
242+
* Returns true if APCu is enabled.
219243
*
220-
* @return bool true if EAccelerator is enabled, false otherwise
244+
* @return bool true if APCu is enabled, false otherwise
221245
*/
222-
public function hasEAccelerator()
246+
public function hasApcu()
223247
{
224-
return $this->data['eaccel_enabled'];
225-
}
226-
227-
/**
228-
* Returns true if APC is enabled.
229-
*
230-
* @return bool true if APC is enabled, false otherwise
231-
*/
232-
public function hasApc()
233-
{
234-
return $this->data['apc_enabled'];
248+
return $this->data['apcu_enabled'];
235249
}
236250

237251
/**
@@ -244,36 +258,6 @@ public function hasZendOpcache()
244258
return $this->data['zend_opcache_enabled'];
245259
}
246260

247-
/**
248-
* Returns true if XCache is enabled.
249-
*
250-
* @return bool true if XCache is enabled, false otherwise
251-
*/
252-
public function hasXCache()
253-
{
254-
return $this->data['xcache_enabled'];
255-
}
256-
257-
/**
258-
* Returns true if WinCache is enabled.
259-
*
260-
* @return bool true if WinCache is enabled, false otherwise
261-
*/
262-
public function hasWinCache()
263-
{
264-
return $this->data['wincache_enabled'];
265-
}
266-
267-
/**
268-
* Returns true if any accelerator is enabled.
269-
*
270-
* @return bool true if any accelerator is enabled, false otherwise
271-
*/
272-
public function hasAccelerator()
273-
{
274-
return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
275-
}
276-
277261
public function getBundles()
278262
{
279263
return $this->data['bundles'];

src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,30 +31,14 @@ public function testCollect()
3131
$this->assertSame('config', $c->getName());
3232
$this->assertSame('testkernel', $c->getAppName());
3333
$this->assertSame(PHP_VERSION, $c->getPhpVersion());
34+
$this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture());
35+
$this->assertSame(\Locale::getDefault() ?: 'n/a', $c->getPhpIntlLocale());
36+
$this->assertSame(date_default_timezone_get(), $c->getPhpTimezone());
3437
$this->assertSame(Kernel::VERSION, $c->getSymfonyVersion());
3538
$this->assertNull($c->getToken());
36-
37-
// if else clause because we don't know it
38-
if (extension_loaded('xdebug')) {
39-
$this->assertTrue($c->hasXDebug());
40-
} else {
41-
$this->assertFalse($c->hasXDebug());
42-
}
43-
44-
// if else clause because we don't know it
45-
if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'))
46-
||
47-
(extension_loaded('apc') && ini_get('apc.enabled'))
48-
||
49-
(extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
50-
||
51-
(extension_loaded('xcache') && ini_get('xcache.cacher'))
52-
||
53-
(extension_loaded('wincache') && ini_get('wincache.ocenabled')))) {
54-
$this->assertTrue($c->hasAccelerator());
55-
} else {
56-
$this->assertFalse($c->hasAccelerator());
57-
}
39+
$this->assertSame(extension_loaded('xdebug'), $c->hasXDebug());
40+
$this->assertSame(extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache());
41+
$this->assertSame(extension_loaded('apcu') && ini_get('apc.enabled'), $c->hasApcu());
5842
}
5943
}
6044

0 commit comments

Comments
 (0)