From f12aff6595a086f92c7927dd1eb09a48ad3deab0 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Nov 2016 13:01:25 +0100 Subject: [PATCH 1/4] Updated the "PHP config" panel in the profiler --- .../views/Collector/config.html.twig | 24 +++---- .../DataCollector/ConfigDataCollector.php | 70 +++++++------------ 2 files changed, 39 insertions(+), 55 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 46234cda974d..8173d2f30976 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -192,17 +192,22 @@
- {{ include('@WebProfiler/Icon/' ~ (collector.hasaccelerator ? 'yes' : 'no') ~ '.svg') }} - PHP acceleration + {{ collector.phparchitecture }} bits + Architecture
- {{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }} - Xdebug + {{ collector.phplocale }} + Locale +
+ +
+ {{ collector.phptimezone }} + Timezone
-
+
{{ include('@WebProfiler/Icon/' ~ (collector.haszendopcache ? 'yes' : 'no') ~ '.svg') }} OPcache @@ -214,13 +219,8 @@
- {{ include('@WebProfiler/Icon/' ~ (collector.hasxcache ? 'yes' : 'no') ~ '.svg') }} - XCache -
- -
- {{ include('@WebProfiler/Icon/' ~ (collector.haseaccelerator ? 'yes' : 'no') ~ '.svg') }} - EAccelerator + {{ include('@WebProfiler/Icon/' ~ (collector.hasxdebug ? 'yes' : 'no') ~ '.svg') }} + Xdebug
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 13db7c431480..8202899d651b 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -67,11 +67,11 @@ public function collect(Request $request, Response $response, \Exception $except 'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a', 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, + 'php_architecture' => PHP_INT_SIZE * 8, + 'php_locale' => \Locale::getDefault() ?: 'n/a', + 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => extension_loaded('xdebug'), - 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'), 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), - 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'), - 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), 'sapi_name' => PHP_SAPI, @@ -136,6 +136,30 @@ public function getPhpVersion() return $this->data['php_version']; } + /** + * @return int The PHP architecture as number of bits (e.g. 32 or 64) + */ + public function getPhpArchitecture() + { + return $this->data['php_architecture']; + } + + /** + * @return string + */ + public function getPhpLocale() + { + return $this->data['php_locale']; + } + + /** + * @return string + */ + public function getPhpTimezone() + { + return $this->data['php_timezone']; + } + /** * Gets the application name. * @@ -176,16 +200,6 @@ public function hasXDebug() return $this->data['xdebug_enabled']; } - /** - * Returns true if EAccelerator is enabled. - * - * @return bool true if EAccelerator is enabled, false otherwise - */ - public function hasEAccelerator() - { - return $this->data['eaccel_enabled']; - } - /** * Returns true if APC is enabled. * @@ -206,36 +220,6 @@ public function hasZendOpcache() return $this->data['zend_opcache_enabled']; } - /** - * Returns true if XCache is enabled. - * - * @return bool true if XCache is enabled, false otherwise - */ - public function hasXCache() - { - return $this->data['xcache_enabled']; - } - - /** - * Returns true if WinCache is enabled. - * - * @return bool true if WinCache is enabled, false otherwise - */ - public function hasWinCache() - { - return $this->data['wincache_enabled']; - } - - /** - * Returns true if any accelerator is enabled. - * - * @return bool true if any accelerator is enabled, false otherwise - */ - public function hasAccelerator() - { - return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache(); - } - public function getBundles() { return $this->data['bundles']; From 921b8ffb6c036c152e6e841199f353c221bd0ce1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Nov 2016 13:28:34 +0100 Subject: [PATCH 2/4] Updated tests --- .../DataCollector/ConfigDataCollectorTest.php | 28 ++++--------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index fea95b4e2b49..526e00b9e6c6 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -31,30 +31,14 @@ public function testCollect() $this->assertSame('config', $c->getName()); $this->assertSame('testkernel', $c->getAppName()); $this->assertSame(PHP_VERSION, $c->getPhpVersion()); + $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); + $this->assertSame(\Locale::getDefault() ?: 'n/a', $c->getPhpLocale()); + $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); $this->assertNull($c->getToken()); - - // if else clause because we don't know it - if (extension_loaded('xdebug')) { - $this->assertTrue($c->hasXDebug()); - } else { - $this->assertFalse($c->hasXDebug()); - } - - // if else clause because we don't know it - if (((extension_loaded('eaccelerator') && ini_get('eaccelerator.enable')) - || - (extension_loaded('apc') && ini_get('apc.enabled')) - || - (extension_loaded('Zend OPcache') && ini_get('opcache.enable')) - || - (extension_loaded('xcache') && ini_get('xcache.cacher')) - || - (extension_loaded('wincache') && ini_get('wincache.ocenabled')))) { - $this->assertTrue($c->hasAccelerator()); - } else { - $this->assertFalse($c->hasAccelerator()); - } + $this->assertSame(extension_loaded('xdebug'), $c->hasXDebug()); + $this->assertSame(extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache()); + $this->assertSame(extension_loaded('apc') && ini_get('apc.enabled'), $c->hasApc()); } } From 29f625977bb90ee899dc1b2dd665d32efa1ac23f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Nov 2016 15:21:59 +0100 Subject: [PATCH 3/4] Renamed "locale" to "Intl locale" --- .../Resources/views/Collector/config.html.twig | 4 ++-- .../HttpKernel/DataCollector/ConfigDataCollector.php | 6 +++--- .../Tests/DataCollector/ConfigDataCollectorTest.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 8173d2f30976..70c2b6ad156d 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -197,8 +197,8 @@
- {{ collector.phplocale }} - Locale + {{ collector.phpintllocale }} + Intl locale
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index 8202899d651b..f6237afe000c 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -68,7 +68,7 @@ public function collect(Request $request, Response $response, \Exception $except 'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a', 'php_version' => PHP_VERSION, 'php_architecture' => PHP_INT_SIZE * 8, - 'php_locale' => \Locale::getDefault() ?: 'n/a', + 'php_intl_locale' => \Locale::getDefault() ?: 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => extension_loaded('xdebug'), 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), @@ -147,9 +147,9 @@ public function getPhpArchitecture() /** * @return string */ - public function getPhpLocale() + public function getPhpIntlLocale() { - return $this->data['php_locale']; + return $this->data['php_intl_locale']; } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 526e00b9e6c6..9506477bfa82 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -32,7 +32,7 @@ public function testCollect() $this->assertSame('testkernel', $c->getAppName()); $this->assertSame(PHP_VERSION, $c->getPhpVersion()); $this->assertSame(PHP_INT_SIZE * 8, $c->getPhpArchitecture()); - $this->assertSame(\Locale::getDefault() ?: 'n/a', $c->getPhpLocale()); + $this->assertSame(\Locale::getDefault() ?: 'n/a', $c->getPhpIntlLocale()); $this->assertSame(date_default_timezone_get(), $c->getPhpTimezone()); $this->assertSame(Kernel::VERSION, $c->getSymfonyVersion()); $this->assertNull($c->getToken()); From 5a7f20ae947193bc855cdc34d3a66ea63e342716 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Nov 2016 15:29:55 +0100 Subject: [PATCH 4/4] Check "APCu" instead of "APC" --- .../Resources/views/Collector/config.html.twig | 4 ++-- .../HttpKernel/DataCollector/ConfigDataCollector.php | 10 +++++----- .../Tests/DataCollector/ConfigDataCollectorTest.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig index 70c2b6ad156d..a413af32bb1b 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/config.html.twig @@ -214,8 +214,8 @@
- {{ include('@WebProfiler/Icon/' ~ (collector.hasapc ? 'yes' : 'no') ~ '.svg') }} - APC + {{ include('@WebProfiler/Icon/' ~ (collector.hasapcu ? 'yes' : 'no') ~ '.svg') }} + APCu
diff --git a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php index f6237afe000c..13b53f18b006 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php @@ -71,7 +71,7 @@ public function collect(Request $request, Response $response, \Exception $except 'php_intl_locale' => \Locale::getDefault() ?: 'n/a', 'php_timezone' => date_default_timezone_get(), 'xdebug_enabled' => extension_loaded('xdebug'), - 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'), + 'apcu_enabled' => extension_loaded('apcu') && ini_get('apc.enabled'), 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'), 'bundles' => array(), 'sapi_name' => PHP_SAPI, @@ -201,13 +201,13 @@ public function hasXDebug() } /** - * Returns true if APC is enabled. + * Returns true if APCu is enabled. * - * @return bool true if APC is enabled, false otherwise + * @return bool true if APCu is enabled, false otherwise */ - public function hasApc() + public function hasApcu() { - return $this->data['apc_enabled']; + return $this->data['apcu_enabled']; } /** diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php index 9506477bfa82..1cc76e02c49c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/ConfigDataCollectorTest.php @@ -38,7 +38,7 @@ public function testCollect() $this->assertNull($c->getToken()); $this->assertSame(extension_loaded('xdebug'), $c->hasXDebug()); $this->assertSame(extension_loaded('Zend OPcache') && ini_get('opcache.enable'), $c->hasZendOpcache()); - $this->assertSame(extension_loaded('apc') && ini_get('apc.enabled'), $c->hasApc()); + $this->assertSame(extension_loaded('apcu') && ini_get('apc.enabled'), $c->hasApcu()); } }