Browse Source

debugger WIP

tags/2.0.0-alpha
Qiang Xue 11 years ago
parent
commit
30ec0afd18
  1. 20
      framework/yii/assets.php
  2. 5
      framework/yii/bootstrap/assets.php
  3. 8
      framework/yii/debug/Module.php
  4. 46
      framework/yii/debug/assets/main.css
  5. 0
      framework/yii/debug/assets/yii.debug.js
  6. 13
      framework/yii/debug/controllers/DefaultController.php
  7. 63
      framework/yii/debug/panels/ConfigPanel.php
  8. 10
      framework/yii/debug/panels/ProfilingPanel.php
  9. 4
      framework/yii/debug/panels/RequestPanel.php
  10. 5
      framework/yii/debug/views/default/index.php
  11. 36
      framework/yii/debug/views/default/toolbar.php
  12. 2
      framework/yii/debug/views/layouts/main.php

20
framework/yii/assets.php

@ -35,13 +35,6 @@ return array(
),
'depends' => array('yii'),
),
'yii/debug' => array(
'sourcePath' => __DIR__ . '/assets',
'js' => array(
'yii.debug.js',
),
'depends' => array('yii'),
),
'yii/punycode' => array(
'sourcePath' => __DIR__ . '/assets',
'js' => array(
@ -55,4 +48,17 @@ return array(
),
'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',
),
),
);

5
framework/yii/bootstrap/assets.php

@ -1,4 +1,9 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
return array(
'yii/bootstrap' => array(

8
framework/yii/debug/Module.php

@ -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.
*/
public $dataPath = '@runtime/debug';
public $historySize = 5;
public $historySize = 50;
public function init()
{
@ -90,6 +90,9 @@ class Module extends \yii\base\Module
protected function corePanels()
{
return array(
'config' => array(
'class' => 'yii\debug\panels\ConfigPanel',
),
'request' => array(
'class' => 'yii\debug\panels\RequestPanel',
),
@ -102,9 +105,6 @@ class Module extends \yii\base\Module
'db' => array(
'class' => 'yii\debug\panels\DbPanel',
),
'config' => array(
'class' => 'yii\debug\panels\ConfigPanel',
),
);
}
}

46
framework/yii/debug/assets/main.css

@ -0,0 +1,46 @@
#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;
}

0
framework/yii/assets/yii.debug.js → framework/yii/debug/assets/yii.debug.js

13
framework/yii/debug/controllers/DefaultController.php

@ -21,13 +21,17 @@ class DefaultController extends Controller
public $module;
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);
if (isset($this->module->panels[$panel])) {
$activePanel = $this->module->panels[$panel];
} else {
$activePanel = reset($this->module->panels);
$activePanel = $this->module->panels['request'];
}
return $this->render('index', array(
'tag' => $tag,
@ -47,6 +51,11 @@ class DefaultController extends Controller
));
}
public function actionPhpinfo()
{
phpinfo();
}
private $_manifest;
protected function getManifest()

63
framework/yii/debug/panels/ConfigPanel.php

File diff suppressed because one or more lines are too long

10
framework/yii/debug/panels/ProfilingPanel.php

@ -49,10 +49,10 @@ class ProfilingPanel extends Panel
$rows = array();
foreach ($timings as $timing) {
$time = sprintf('%0.5f', $timing[3]);
$procedure = str_repeat('&nbsp;', $timing[0] * 4) . Html::encode($timing[1]);
$time = sprintf('%.1f ms', $timing[3] * 1000);
$procedure = str_repeat('<span class="indent"></span>', $timing[0]) . Html::encode($timing[1]);
$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);
@ -62,9 +62,9 @@ class ProfilingPanel extends Panel
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead>
<tr>
<th>Category</th>
<th style="width: 80px;">Time</th>
<th style="width: 220px;">Category</th>
<th>Procedure</th>
<th>Time</th>
</tr>
</thead>
<tbody>

4
framework/yii/debug/panels/RequestPanel.php

@ -25,8 +25,8 @@ class RequestPanel extends Panel
public function getSummary()
{
$memory = sprintf('%.2fMB', $this->data['memory'] / 1048576);
$time = sprintf('%.3fs', $this->data['time']);
$memory = sprintf('%.1f MB', $this->data['memory'] / 1048576);
$time = number_format($this->data['time'] * 1000) . ' ms';
return <<<EOD
<div class="yii-debug-toolbar-block">

5
framework/yii/debug/views/default/index.php

@ -12,12 +12,15 @@ use yii\helpers\Html;
*/
$this->registerAssetBundle('yii/bootstrap/dropdown');
$this->title = 'Yii Debugger';
?>
<div class="default-index">
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<span class="brand">Yii Debugger</span>
<?php foreach ($panels as $panel): ?>
<?php echo $panel->getSummary(); ?>
<?php endforeach; ?>
</div>
</div>
</div>

36
framework/yii/debug/views/default/toolbar.php

@ -12,24 +12,46 @@ use yii\helpers\Html;
left: 0;
right: 0;
bottom: 0;
background-color: #eee;
border-top: 1px solid #ccc;
margin: 0;
padding: 5px 10px;
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 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>
<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 echo $panel->getSummary(); ?>
<?php endforeach; ?>

2
framework/yii/debug/views/layouts/main.php

@ -5,7 +5,7 @@
*/
use yii\helpers\Html;
Yii::$app->getView()->registerAssetBundle('yii/bootstrap/responsive');
Yii::$app->getView()->registerAssetBundle('yii/debug');
?>
<!DOCTYPE html>
<html>

Loading…
Cancel
Save