Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

105 linhas
2.5KB

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