Qiang Xue
12 years ago
14 changed files with 324 additions and 75 deletions
@ -0,0 +1,45 @@
|
||||
<?php |
||||
/** |
||||
* @link http://www.yiiframework.com/ |
||||
* @copyright Copyright (c) 2008 Yii Software LLC |
||||
* @license http://www.yiiframework.com/license/ |
||||
*/ |
||||
|
||||
namespace yii\debug; |
||||
|
||||
use yii\base\Component; |
||||
|
||||
/** |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class Panel extends Component |
||||
{ |
||||
public $id; |
||||
public $data; |
||||
|
||||
public function getName() |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function getSummary() |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function getDetail() |
||||
{ |
||||
return ''; |
||||
} |
||||
|
||||
public function save() |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
public function load($data) |
||||
{ |
||||
$this->data = $data; |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
<?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; |
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class ConfigPanel extends Panel |
||||
{ |
||||
public function getName() |
||||
{ |
||||
return 'Config'; |
||||
} |
||||
|
||||
public function getSummary() |
||||
{ |
||||
$link = Html::a('more details', array('index', 'tag' => $this->data['tag'])); |
||||
return <<<EOD |
||||
<div class="yii-debug-toolbar-block"> |
||||
PHP: {$this->data['phpVersion']}, |
||||
Yii: {$this->data['phpVersion']}, |
||||
$link |
||||
</div> |
||||
EOD; |
||||
} |
||||
|
||||
public function getDetail() |
||||
{ |
||||
return '<h2>Config</h2>'; |
||||
} |
||||
|
||||
public function save() |
||||
{ |
||||
return array( |
||||
'tag' => Yii::$app->getLog()->getTag(), |
||||
'phpVersion' => PHP_VERSION, |
||||
'yiiVersion' => Yii::getVersion(), |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
<?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; |
||||
|
||||
/** |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class LogPanel extends Panel |
||||
{ |
||||
public function getName() |
||||
{ |
||||
return 'Logs'; |
||||
} |
||||
|
||||
public function getSummary() |
||||
{ |
||||
$count = count($this->data['messages']); |
||||
return <<<EOD |
||||
<div class="yii-debug-toolbar-block"> |
||||
Log messages: $count |
||||
</div> |
||||
EOD; |
||||
} |
||||
|
||||
public function getDetail() |
||||
{ |
||||
return '<h2>Logs</h2>'; |
||||
} |
||||
|
||||
public function save() |
||||
{ |
||||
return array( |
||||
'messages' => Yii::$app->getLog()->targets['debug']->messages, |
||||
); |
||||
} |
||||
} |
@ -0,0 +1,57 @@
|
||||
<?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\debug\Panel; |
||||
|
||||
/** |
||||
* @author Qiang Xue <qiang.xue@gmail.com> |
||||
* @since 2.0 |
||||
*/ |
||||
class RequestPanel extends Panel |
||||
{ |
||||
public function getName() |
||||
{ |
||||
return 'Request'; |
||||
} |
||||
|
||||
public function getSummary() |
||||
{ |
||||
$memory = sprintf('%.2fMB', $this->data['memory'] / 1048576); |
||||
$time = sprintf('%.3fs', $this->data['time']); |
||||
|
||||
return <<<EOD |
||||
<div class="yii-debug-toolbar-block"> |
||||
Peak memory: $memory |
||||
</div> |
||||
|
||||
<div class="yii-debug-toolbar-block"> |
||||
Time spent: $time |
||||
</div> |
||||
EOD; |
||||
} |
||||
|
||||
public function getDetail() |
||||
{ |
||||
return '<h2>Request</h2>'; |
||||
} |
||||
|
||||
public function save() |
||||
{ |
||||
return array( |
||||
'memory' => memory_get_peak_usage(), |
||||
'time' => microtime(true) - YII_BEGIN_TIME, |
||||
'SERVER' => $_SERVER, |
||||
'GET' => $_GET, |
||||
'POST' => $_POST, |
||||
'COOKIE' => $_COOKIE, |
||||
'FILES' => empty($_FILES) ? array() : $_FILES, |
||||
'SESSION' => empty($_SESSION) ? array() : $_SESSION, |
||||
); |
||||
} |
||||
} |
@ -1 +1,16 @@
|
||||
here we are |
||||
<?php |
||||
|
||||
use yii\helpers\Html; |
||||
|
||||
/** |
||||
* @var \yii\base\View $this |
||||
* @var string $tag |
||||
* @var \yii\debug\Panel[] $panels |
||||
* @var \yii\debug\Panel $activePanel |
||||
*/ |
||||
?> |
||||
<?php foreach ($panels as $panel): ?> |
||||
<?php echo Html::a(Html::encode($panel->getName()), array('debug/default/index', 'tag' => $tag, 'panel' => $panel->id)); ?><br>
|
||||
<?php endforeach; ?> |
||||
|
||||
<?php echo $activePanel->getDetail(); ?> |
||||
|
@ -1,40 +1,31 @@
|
||||
<?php use yii\helpers\Html; |
||||
|
||||
echo Html::style(" |
||||
<?php |
||||
/** |
||||
* @var \yii\base\View $this |
||||
* @var \yii\debug\Panel[] $panels |
||||
*/ |
||||
?> |
||||
<style> |
||||
#yii-debug-toolbar { |
||||
position: fixed; |
||||
left: 0; |
||||
right: 0; |
||||
bottom: 0; |
||||
background-color: #eee; |
||||
border-top: 1px solid #ccc; |
||||
margin: 0; |
||||
padding: 5px 10px; |
||||
z-index: 1000000; |
||||
font: 11px Verdana, Arial, sans-serif; |
||||
text-align: left; |
||||
position: fixed; |
||||
left: 0; |
||||
right: 0; |
||||
bottom: 0; |
||||
background-color: #eee; |
||||
border-top: 1px solid #ccc; |
||||
margin: 0; |
||||
padding: 5px 10px; |
||||
z-index: 1000000; |
||||
font: 11px Verdana, Arial, sans-serif; |
||||
text-align: left; |
||||
} |
||||
.yii-debug-toolbar-block { |
||||
float: left; |
||||
margin: 0 10px; |
||||
"); |
||||
?> |
||||
<div id="yii-debug-toolbar"> |
||||
<div class="yii-debug-toolbar-block"> |
||||
<?php echo Html::a('more details', array('index', 'tag' => $tag)); ?> |
||||
</div> |
||||
|
||||
<div class="yii-debug-toolbar-block"> |
||||
Peak memory: <?php echo sprintf('%.2fMB', $memory / 1048576); ?> |
||||
</div> |
||||
|
||||
<div class="yii-debug-toolbar-block"> |
||||
Time spent: <?php echo sprintf('%.3fs', $time); ?> |
||||
</div> |
||||
|
||||
<div class="yii-debug-toolbar-block"> |
||||
</div> |
||||
} |
||||
</style> |
||||
|
||||
<div class="yii-debug-toolbar-block"> |
||||
</div> |
||||
<div id="yii-debug-toolbar"> |
||||
<?php foreach ($panels as $panel): ?> |
||||
<?php echo $panel->getSummary(); ?> |
||||
<?php endforeach; ?> |
||||
</div> |
||||
|
Loading…
Reference in new issue