Commit 30ec0afd by Qiang Xue

debugger WIP

parent faf445bb
...@@ -35,13 +35,6 @@ return array( ...@@ -35,13 +35,6 @@ return array(
), ),
'depends' => array('yii'), 'depends' => array('yii'),
), ),
'yii/debug' => array(
'sourcePath' => __DIR__ . '/assets',
'js' => array(
'yii.debug.js',
),
'depends' => array('yii'),
),
'yii/punycode' => array( 'yii/punycode' => array(
'sourcePath' => __DIR__ . '/assets', 'sourcePath' => __DIR__ . '/assets',
'js' => array( 'js' => array(
...@@ -55,4 +48,17 @@ return array( ...@@ -55,4 +48,17 @@ return array(
), ),
'depends' => array('yii/jquery'), 'depends' => array('yii/jquery'),
), ),
'yii/debug' => array(
'sourcePath' => __DIR__ . '/debug/assets',
'css' => array(
'main.css',
),
'js' => array(
'yii.debug.js',
),
'depends' => array(
'yii',
'yii/bootstrap/responsive',
),
),
); );
<?php <?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
return array( return array(
'yii/bootstrap' => array( 'yii/bootstrap' => array(
......
...@@ -39,7 +39,7 @@ class Module extends \yii\base\Module ...@@ -39,7 +39,7 @@ class Module extends \yii\base\Module
* @var string the directory storing the debugger data files. This can be specified using a path alias. * @var string the directory storing the debugger data files. This can be specified using a path alias.
*/ */
public $dataPath = '@runtime/debug'; public $dataPath = '@runtime/debug';
public $historySize = 5; public $historySize = 50;
public function init() public function init()
{ {
...@@ -90,6 +90,9 @@ class Module extends \yii\base\Module ...@@ -90,6 +90,9 @@ class Module extends \yii\base\Module
protected function corePanels() protected function corePanels()
{ {
return array( return array(
'config' => array(
'class' => 'yii\debug\panels\ConfigPanel',
),
'request' => array( 'request' => array(
'class' => 'yii\debug\panels\RequestPanel', 'class' => 'yii\debug\panels\RequestPanel',
), ),
...@@ -102,9 +105,6 @@ class Module extends \yii\base\Module ...@@ -102,9 +105,6 @@ class Module extends \yii\base\Module
'db' => array( 'db' => array(
'class' => 'yii\debug\panels\DbPanel', 'class' => 'yii\debug\panels\DbPanel',
), ),
'config' => array(
'class' => 'yii\debug\panels\ConfigPanel',
),
); );
} }
} }
#yii-debug-toolbar {
position: fixed;
left: 0;
right: 0;
bottom: 0;
margin: 0;
padding: 0;
z-index: 1000000;
font: 11px Verdana, Arial, sans-serif;
text-align: left;
height: 38px;
border-top: 1px solid #ccc;
background: rgb(237,237,237);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VkZWRlZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUzJSIgc3RvcC1jb2xvcj0iI2Y2ZjZmNiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(237,237,237,1) 0%, rgba(246,246,246,1) 53%, rgba(255,255,255,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(237,237,237,1)), color-stop(53%,rgba(246,246,246,1)), color-stop(100%,rgba(255,255,255,1)));
background: -webkit-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
background: -o-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
background: -ms-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
background: linear-gradient(to bottom, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ededed', endColorstr='#ffffff',GradientType=0 );
}
.yii-debug-toolbar-block {
float: left;
margin: 0;
border-right: 1px solid #e4e4e4;
padding: 4px 8px;
line-height: 32px;
}
.yii-debug-toolbar-block a {
text-decoration: none;
color: black !important;
}
.yii-debug-toolbar-block span {
}
.yii-debug-toolbar-block img {
vertical-align: middle;
}
span.indent {
color: #ccc;
}
...@@ -21,13 +21,17 @@ class DefaultController extends Controller ...@@ -21,13 +21,17 @@ class DefaultController extends Controller
public $module; public $module;
public $layout = 'main'; public $layout = 'main';
public function actionIndex($tag, $panel = null) public function actionIndex($tag = null, $panel = null)
{ {
if ($tag === null) {
$tags = array_keys($this->getManifest());
$tag = end($tags);
}
$meta = $this->loadData($tag); $meta = $this->loadData($tag);
if (isset($this->module->panels[$panel])) { if (isset($this->module->panels[$panel])) {
$activePanel = $this->module->panels[$panel]; $activePanel = $this->module->panels[$panel];
} else { } else {
$activePanel = reset($this->module->panels); $activePanel = $this->module->panels['request'];
} }
return $this->render('index', array( return $this->render('index', array(
'tag' => $tag, 'tag' => $tag,
...@@ -47,6 +51,11 @@ class DefaultController extends Controller ...@@ -47,6 +51,11 @@ class DefaultController extends Controller
)); ));
} }
public function actionPhpinfo()
{
phpinfo();
}
private $_manifest; private $_manifest;
protected function getManifest() protected function getManifest()
......
...@@ -49,10 +49,10 @@ class ProfilingPanel extends Panel ...@@ -49,10 +49,10 @@ class ProfilingPanel extends Panel
$rows = array(); $rows = array();
foreach ($timings as $timing) { foreach ($timings as $timing) {
$time = sprintf('%0.5f', $timing[3]); $time = sprintf('%.1f ms', $timing[3] * 1000);
$procedure = str_repeat('&nbsp;', $timing[0] * 4) . Html::encode($timing[1]); $procedure = str_repeat('<span class="indent">→</span>', $timing[0]) . Html::encode($timing[1]);
$category = Html::encode($timing[2]); $category = Html::encode($timing[2]);
$rows[] = "<tr><td>$category</td><td>$procedure</td><td>{$time}s</td>"; $rows[] = "<tr><td style=\"width: 80px;\">$time</td><td style=\"width: 220px;\">$category</td><td>$procedure</td>";
} }
$rows = implode("\n", $rows); $rows = implode("\n", $rows);
...@@ -62,9 +62,9 @@ class ProfilingPanel extends Panel ...@@ -62,9 +62,9 @@ class ProfilingPanel extends Panel
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;"> <table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead> <thead>
<tr> <tr>
<th>Category</th> <th style="width: 80px;">Time</th>
<th style="width: 220px;">Category</th>
<th>Procedure</th> <th>Procedure</th>
<th>Time</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
......
...@@ -25,8 +25,8 @@ class RequestPanel extends Panel ...@@ -25,8 +25,8 @@ class RequestPanel extends Panel
public function getSummary() public function getSummary()
{ {
$memory = sprintf('%.2fMB', $this->data['memory'] / 1048576); $memory = sprintf('%.1f MB', $this->data['memory'] / 1048576);
$time = sprintf('%.3fs', $this->data['time']); $time = number_format($this->data['time'] * 1000) . ' ms';
return <<<EOD return <<<EOD
<div class="yii-debug-toolbar-block"> <div class="yii-debug-toolbar-block">
......
...@@ -12,12 +12,15 @@ use yii\helpers\Html; ...@@ -12,12 +12,15 @@ use yii\helpers\Html;
*/ */
$this->registerAssetBundle('yii/bootstrap/dropdown'); $this->registerAssetBundle('yii/bootstrap/dropdown');
$this->title = 'Yii Debugger';
?> ?>
<div class="default-index"> <div class="default-index">
<div class="navbar"> <div class="navbar">
<div class="navbar-inner"> <div class="navbar-inner">
<div class="container"> <div class="container">
<span class="brand">Yii Debugger</span> <?php foreach ($panels as $panel): ?>
<?php echo $panel->getSummary(); ?>
<?php endforeach; ?>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -12,24 +12,46 @@ use yii\helpers\Html; ...@@ -12,24 +12,46 @@ use yii\helpers\Html;
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
background-color: #eee;
border-top: 1px solid #ccc;
margin: 0; margin: 0;
padding: 5px 10px; padding: 0;
z-index: 1000000; z-index: 1000000;
font: 11px Verdana, Arial, sans-serif; font: 11px Verdana, Arial, sans-serif;
text-align: left; text-align: left;
height: 38px;
border-top: 1px solid #ccc;
background: rgb(237,237,237);
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2VkZWRlZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjUzJSIgc3RvcC1jb2xvcj0iI2Y2ZjZmNiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNmZmZmZmYiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, rgba(237,237,237,1) 0%, rgba(246,246,246,1) 53%, rgba(255,255,255,1) 100%);
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(237,237,237,1)), color-stop(53%,rgba(246,246,246,1)), color-stop(100%,rgba(255,255,255,1)));
background: -webkit-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
background: -o-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
background: -ms-linear-gradient(top, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
background: linear-gradient(to bottom, rgba(237,237,237,1) 0%,rgba(246,246,246,1) 53%,rgba(255,255,255,1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ededed', endColorstr='#ffffff',GradientType=0 );
} }
.yii-debug-toolbar-block { .yii-debug-toolbar-block {
float: left; float: left;
margin: 0 10px; margin: 0;
border-right: 1px solid #e4e4e4;
padding: 4px 8px;
line-height: 32px;
}
.yii-debug-toolbar-block a {
text-decoration: none;
color: black !important;
}
.yii-debug-toolbar-block span {
}
.yii-debug-toolbar-block img {
vertical-align: middle;
} }
</style> </style>
<div id="yii-debug-toolbar"> <div id="yii-debug-toolbar">
<div class="yii-debug-toolbar-block">
<?php echo Html::a('Yii Debugger', array('index', 'tag' => $tag)); ?>
</div>
<?php foreach ($panels as $panel): ?> <?php foreach ($panels as $panel): ?>
<?php echo $panel->getSummary(); ?> <?php echo $panel->getSummary(); ?>
<?php endforeach; ?> <?php endforeach; ?>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*/ */
use yii\helpers\Html; use yii\helpers\Html;
Yii::$app->getView()->registerAssetBundle('yii/bootstrap/responsive'); Yii::$app->getView()->registerAssetBundle('yii/debug');
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment