Skip to content

Updated the "PHP config" panel in the profiler #20697

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,35 +192,35 @@
</div>

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

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

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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_intl_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'),
'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,
Expand Down Expand Up @@ -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 getPhpIntlLocale()
{
return $this->data['php_intl_locale'];
}

/**
* @return string
*/
public function getPhpTimezone()
{
return $this->data['php_timezone'];
}

/**
* Gets the application name.
*
Expand Down Expand Up @@ -177,23 +201,13 @@ public function hasXDebug()
}

/**
* Returns true if EAccelerator is enabled.
* Returns true if APCu is enabled.
*
* @return bool true if EAccelerator is enabled, false otherwise
* @return bool true if APCu is enabled, false otherwise
*/
public function hasEAccelerator()
public function hasApcu()
{
return $this->data['eaccel_enabled'];
}

/**
* Returns true if APC is enabled.
*
* @return bool true if APC is enabled, false otherwise
*/
public function hasApc()
{
return $this->data['apc_enabled'];
return $this->data['apcu_enabled'];
}

/**
Expand All @@ -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'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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->getPhpIntlLocale());
$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('apcu') && ini_get('apc.enabled'), $c->hasApcu());
}
}

Expand Down