Blame view

vendor/yiisoft/yii2-debug/panels/ConfigPanel.php 2.53 KB
abf1649b   andryeyev   Чистая установка ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
  <?php
  /**
   * @link http://www.yiiframework.com/
   * @copyright Copyright (c) 2008 Yii Software LLC
   * @license http://www.yiiframework.com/license/
   */
  
  namespace yii\debug\panels;
  
  use Yii;
  use yii\debug\Panel;
  
  /**
   * Debugger panel that collects and displays application configuration and environment.
   *
   * @property array $extensions This property is read-only.
   * @property array $phpInfo This property is read-only.
   *
   * @author Qiang Xue <qiang.xue@gmail.com>
   * @since 2.0
   */
  class ConfigPanel extends Panel
  {
      /**
       * @inheritdoc
       */
      public function getName()
      {
          return 'Configuration';
      }
  
      /**
       * @inheritdoc
       */
      public function getSummary()
      {
          return Yii::$app->view->render('panels/config/summary', ['panel' => $this]);
      }
  
      /**
       * @inheritdoc
       */
      public function getDetail()
      {
          return Yii::$app->view->render('panels/config/detail', ['panel' => $this]);
      }
  
      /**
       * Returns data about extensions
       *
       * @return array
       */
      public function getExtensions()
      {
          $data = [];
          foreach ($this->data['extensions'] as $extension) {
              $data[$extension['name']] = $extension['version'];
          }
          ksort($data);
  
          return $data;
      }
  
      /**
       * Returns the BODY contents of the phpinfo() output
       *
       * @return array
       */
      public function getPhpInfo()
      {
          ob_start();
          phpinfo();
          $pinfo = ob_get_contents();
          ob_end_clean();
          $phpinfo = preg_replace('%^.*<body>(.*)</body>.*$%ms', '$1', $pinfo);
          $phpinfo = str_replace('<table', '<div class="table-responsive"><table class="table table-condensed table-bordered table-striped table-hover config-php-info-table" ', $phpinfo);
          $phpinfo = str_replace('</table>', '</table></div>', $phpinfo);
          return $phpinfo;
      }
  
      /**
       * @inheritdoc
       */
      public function save()
      {
          return [
              'phpVersion' => PHP_VERSION,
              'yiiVersion' => Yii::getVersion(),
              'application' => [
                  'yii' => Yii::getVersion(),
                  'name' => Yii::$app->name,
                  'env' => YII_ENV,
                  'debug' => YII_DEBUG,
              ],
              'php' => [
                  'version' => PHP_VERSION,
                  'xdebug' => extension_loaded('xdebug'),
                  'apc' => extension_loaded('apc'),
                  'memcache' => extension_loaded('memcache'),
              ],
              'extensions' => Yii::$app->extensions,
          ];
      }
  }