Skip to content

Commit

Permalink
Add support for detection of Zend OPcache as an accelerator
Browse files Browse the repository at this point in the history
  • Loading branch information
Tatsh committed Apr 15, 2013
1 parent 46efc9b commit 8e9cb3b
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
Expand Up @@ -171,6 +171,10 @@
<th>APC</th>
<td>{{ collector.hasapc ? 'enabled' : 'disabled' }}</td>
</tr>
<tr>
<th>Zend OPcache</th>
<td>{{ collector.haszendopcache ? 'enabled' : 'disabled' }}</td>
</tr>
<tr>
<th>EAccelerator</th>
<td>{{ collector.haseaccelerator ? 'enabled' : 'disabled' }}</td>
Expand Down
Expand Up @@ -56,21 +56,22 @@ public function setKernel(KernelInterface $kernel = null)
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data = array(
'app_name' => $this->name,
'app_version' => $this->version,
'token' => $response->headers->get('X-Debug-Token'),
'symfony_version' => Kernel::VERSION,
'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
'php_version' => PHP_VERSION,
'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'),
'bundles' => array(),
'sapi_name' => php_sapi_name()
'app_name' => $this->name,
'app_version' => $this->version,
'token' => $response->headers->get('X-Debug-Token'),
'symfony_version' => Kernel::VERSION,
'name' => isset($this->kernel) ? $this->kernel->getName() : 'n/a',
'env' => isset($this->kernel) ? $this->kernel->getEnvironment() : 'n/a',
'debug' => isset($this->kernel) ? $this->kernel->isDebug() : 'n/a',
'php_version' => PHP_VERSION,
'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_name()
);

if (isset($this->kernel)) {
Expand Down Expand Up @@ -180,6 +181,16 @@ public function hasApc()
return $this->data['apc_enabled'];
}

/**
* Returns true if Zend OPcache is enabled
*
* @return Boolean true if Zend OPcache is enabled, false otherwise
*/
public function hasZendOpcache()
{
return $this->data['zend_opcache_enabled'];
}

/**
* Returns true if XCache is enabled.
*
Expand Down Expand Up @@ -207,7 +218,7 @@ public function hasWinCache()
*/
public function hasAccelerator()
{
return $this->hasApc() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
}

public function getBundles()
Expand Down
Expand Up @@ -53,6 +53,8 @@ public function testCollect()
||
(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')))) {
Expand Down

0 comments on commit 8e9cb3b

Please sign in to comment.