3 namespace Drupal\webprofiler\DataCollector;
5 use Drupal\Core\Routing\LinkGeneratorTrait;
6 use Drupal\Core\StringTranslation\StringTranslationTrait;
7 use Drupal\webprofiler\DrupalDataCollectorInterface;
8 use Symfony\Component\HttpKernel\DataCollector\DataCollector;
9 use Symfony\Component\HttpFoundation\Request;
10 use Symfony\Component\HttpFoundation\Response;
13 * Provides a data collector to collect all kind of php information.
15 class PhpConfigDataCollector extends DataCollector implements DrupalDataCollectorInterface {
17 use StringTranslationTrait, DrupalDataCollectorTrait, LinkGeneratorTrait;
22 public function collect(Request $request, Response $response, \Exception $exception = NULL) {
24 'token' => $response->headers->get('X-Debug-Token'),
25 'php_version' => PHP_VERSION,
26 'xdebug_enabled' => extension_loaded('xdebug'),
27 'xhprof_enabled' => extension_loaded('xhprof'),
28 'eaccel_enabled' => extension_loaded('eaccelerator') && ini_get('eaccelerator.enable'),
29 'apc_enabled' => extension_loaded('apc') && ini_get('apc.enabled'),
30 'xcache_enabled' => extension_loaded('xcache') && ini_get('xcache.cacher'),
31 'wincache_enabled' => extension_loaded('wincache') && ini_get('wincache.ocenabled'),
32 'zend_opcache_enabled' => extension_loaded('Zend OPcache') && ini_get('opcache.enable'),
33 'sapi_name' => php_sapi_name()
40 * @return string The token
42 public function getToken() {
43 return $this->data['token'];
47 * Gets the PHP version.
49 * @return string The PHP version
51 public function getPhpVersion() {
52 return $this->data['php_version'];
56 * Returns true if the XDebug is enabled.
58 * @return Boolean true if XDebug is enabled, false otherwise
60 public function hasXDebug() {
61 return $this->data['xdebug_enabled'];
65 * Returns true if the XHProf is enabled.
67 * @return Boolean true if XHProf is enabled, false otherwise
69 public function hasXHProf() {
70 return $this->data['xhprof_enabled'];
74 * Returns true if EAccelerator is enabled.
76 * @return Boolean true if EAccelerator is enabled, false otherwise
78 public function hasEAccelerator() {
79 return $this->data['eaccel_enabled'];
83 * Returns true if APC is enabled.
85 * @return Boolean true if APC is enabled, false otherwise
87 public function hasApc() {
88 return $this->data['apc_enabled'];
92 * Returns true if Zend OPcache is enabled
94 * @return Boolean true if Zend OPcache is enabled, false otherwise
96 public function hasZendOpcache() {
97 return $this->data['zend_opcache_enabled'];
101 * Returns true if XCache is enabled.
103 * @return Boolean true if XCache is enabled, false otherwise
105 public function hasXCache() {
106 return $this->data['xcache_enabled'];
110 * Returns true if WinCache is enabled.
112 * @return Boolean true if WinCache is enabled, false otherwise
114 public function hasWinCache() {
115 return $this->data['wincache_enabled'];
119 * Returns true if any accelerator is enabled.
121 * @return Boolean true if any accelerator is enabled, false otherwise
123 public function hasAccelerator() {
124 return $this->hasApc() || $this->hasZendOpcache() || $this->hasEAccelerator() || $this->hasXCache() || $this->hasWinCache();
128 * Gets the PHP SAPI name.
130 * @return string The environment
132 public function getSapiName() {
133 return $this->data['sapi_name'];
139 public function getTitle() {
140 return $this->t('PHP Config');
146 public function getPanelSummary() {
147 return $this->t('PHP: @version', ['@version' => $this->getPhpVersion()]);
153 public function getName() {
160 public function getIcon() {
161 return 'iVBORw0KGgoAAAANSUhEUgAAABUAAAAcCAMAAAC5xgRsAAAAZlBMVEX///////////////////////////////////////////////////////////////////////////////////////////+ZmZmZmZlISEhJSUmdnZ1HR0fR0dFZWVlpaWlfX18/Pz+puygPAAAAIXRSTlMACwwlJygpLzIzNjs8QEtMUmd6e32AucDBw8fIydTm6u5l8MjvAAAAo0lEQVR42r2P2Q6CMBBFL6XsZRGRfZv//0nbDBNEE19MnJeTc5ILKf58ahiUwzy/AJpIWwREwQnEXRdbGCLjrO+djWRvVMiJcigxB7viGogxDdJpSmHEmCVPS7YczJvgUu+CS30IvtbNYZMvsGVo2mVpG/kbm4auiCpdcC3YPCAhSpAdUzaAn6qPKZtUT6ZSzb4bi2hdo9MQ1nX4ASjfV+/4/Z40pyCHrNTbIgAAAABJRU5ErkJggg==';