Skip to content

Commit 531053b

Browse files
javiereguiluzfabpot
authored andcommitted
Updated the "PHP config" panel in the profiler
1 parent e765849 commit 531053b

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
@@ -192,35 +192,35 @@
192192
</div>
193193

194194
<div class="metric">
195-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasaccelerator ? 'yes' : 'no') ~ '.svg') }}</span>
196-
<span class="label">PHP acceleration</span>
195+
<span class="value">{{ collector.phparchitecture }} <span class="unit">bits</span></span>
196+
<span class="label">Architecture</span>
197197
</div>
198198

199199
<div class="metric">
200-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }}</span>
201-
<span class="label">Xdebug</span>
200+
<span class="value">{{ collector.phpintllocale }}</span>
201+
<span class="label">Intl locale</span>
202202
</div>
203-
</div>
204203

205-
<div class="metrics metrics-horizontal">
206204
<div class="metric">
207-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
208-
<span class="label">OPcache</span>
205+
<span class="value">{{ collector.phptimezone }}</span>
206+
<span class="label">Timezone</span>
209207
</div>
208+
</div>
210209

210+
<div class="metrics">
211211
<div class="metric">
212-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasapc ? 'yes' : 'no') ~ '.svg') }}</span>
213-
<span class="label">APC</span>
212+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }}</span>
213+
<span class="label">OPcache</span>
214214
</div>
215215

216216
<div class="metric">
217-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxcache ? 'yes' : 'no') ~ '.svg') }}</span>
218-
<span class="label">XCache</span>
217+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }}</span>
218+
<span class="label">APCu</span>
219219
</div>
220220

221221
<div class="metric">
222-
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.haseaccelerator ? 'yes' : 'no') ~ '.svg') }}</span>
223-
<span class="label">EAccelerator</span>
222+
<span class="value">{{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }}</span>
223+
<span class="label">Xdebug</span>
224224
</div>
225225
</div>
226226

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,
@@ -136,6 +136,30 @@ public function getPhpVersion()
136136
return $this->data['php_version'];
137137
}
138138

139+
/**
140+
* @return int The PHP architecture as number of bits (e.g. 32 or 64)
141+
*/
142+
public function getPhpArchitecture()
143+
{
144+
return $this->data['php_architecture'];
145+
}
146+
147+
/**
148+
* @return string
149+
*/
150+
public function getPhpIntlLocale()
151+
{
152+
return $this->data['php_intl_locale'];
153+
}
154+
155+
/**
156+
* @return string
157+
*/
158+
public function getPhpTimezone()
159+
{
160+
return $this->data['php_timezone'];
161+
}
162+
139163
/**
140164
* Gets the application name.
141165
*
@@ -177,23 +201,13 @@ public function hasXDebug()
177201
}
178202

179203
/**
180-
* Returns true if EAccelerator is enabled.
204+
* Returns true if APCu is enabled.
181205
*
182-
* @return bool true if EAccelerator is enabled, false otherwise
206+
* @return bool true if APCu is enabled, false otherwise
183207
*/
184-
public function hasEAccelerator()
208+
public function hasApcu()
185209
{
186-
return $this->data['eaccel_enabled'];
187-
}
188-
189-
/**
190-
* Returns true if APC is enabled.
191-
*
192-
* @return bool true if APC is enabled, false otherwise
193-
*/
194-
public function hasApc()
195-
{
196-
return $this->data['apc_enabled'];
210+
return $this->data['apcu_enabled'];
197211
}
198212

199213
/**
@@ -206,36 +220,6 @@ public function hasZendOpcache()
206220
return $this->data['zend_opcache_enabled'];
207221
}
208222

209-
/**
210-
* Returns true if XCache is enabled.
211-
*
212-
* @return bool true if XCache is enabled, false otherwise
213-
*/
214-
public function hasXCache()
215-
{
216-
return $this->data['xcache_enabled'];
217-
}
218-
219-
/**
220-
* Returns true if WinCache is enabled.
221-
*
222-
* @return bool true if WinCache is enabled, false otherwise
223-
*/
224-
public function hasWinCache()
225-
{
226-
return $this->data['wincache_enabled'];
227-
}
228-
229-
/**
230-
* Returns true if any accelerator is enabled.
231-
*
232-
* @return bool true if any accelerator is enabled, false otherwise
233-
*/
234-
public function hasAccelerator()
235-
{
236-
return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
237-
}
238-
239223
public function getBundles()
240224
{
241225
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)