Commit e1decbc9 by Smotrov Dmitriy

Merge pull request #2 from yiisoft/master

Merge from yiisoft/master
parents 4efc097e 30ec0afd
......@@ -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',
),
),
);
......@@ -7,6 +7,8 @@
namespace yii\base;
use Yii;
/**
* Action is the base class for all controller action classes.
*
......@@ -75,6 +77,10 @@ class Action extends Component
throw new InvalidConfigException(get_class($this) . ' must define a "run()" method.');
}
$args = $this->controller->bindActionParams($this, $params);
Yii::info('Running "' . get_class($this) . '::run()" with parameters: ' . var_export($args, true), __METHOD__);
if (Yii::$app->requestedParams === null) {
Yii::$app->requestedParams = $args;
}
return call_user_func_array(array($this, 'run'), $args);
}
}
......@@ -78,6 +78,18 @@ abstract class Application extends Module
* Defaults to 256KB.
*/
public $memoryReserveSize = 262144;
/**
* @var string the requested route
*/
public $requestedRoute;
/**
* @var Action the requested Action. If null, it means the request cannot be resolved into an action.
*/
public $requestedAction;
/**
* @var array the parameters supplied to the requested action.
*/
public $requestedParams;
/**
* @var string Used to reserve memory for fatal error handler.
......
......@@ -107,6 +107,10 @@ class Controller extends Component
{
$action = $this->createAction($id);
if ($action !== null) {
Yii::trace("Route to run: " . $action->getUniqueId(), __METHOD__);
if (Yii::$app->requestedAction === null) {
Yii::$app->requestedAction = $action;
}
$oldAction = $this->action;
$this->action = $action;
$result = null;
......
......@@ -7,6 +7,8 @@
namespace yii\base;
use Yii;
/**
* InlineAction represents an action that is defined as a controller method.
*
......@@ -44,6 +46,10 @@ class InlineAction extends Action
public function runWithParams($params)
{
$args = $this->controller->bindActionParams($this, $params);
Yii::info("Running '" . get_class($this->controller) . '::' . $this->actionMethod . "()' with parameters: " . var_export($args, true), __METHOD__);
if (Yii::$app->requestedParams === null) {
Yii::$app->requestedParams = $args;
}
return call_user_func_array(array($this->controller, $this->actionMethod), $args);
}
}
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
return array(
'yii/bootstrap' => array(
......
......@@ -92,6 +92,7 @@ class Application extends \yii\base\Application
public function handleRequest($request)
{
list ($route, $params) = $request->resolve();
$this->requestedRoute = $route;
$result = $this->runAction($route, $params);
if ($result instanceof Response) {
return $result;
......
......@@ -21,13 +21,16 @@ class LogTarget extends Target
*/
public $module;
public $tag;
public $historySize = 20;
/**
* @param \yii\debug\Module $module
* @param array $config
*/
public function __construct($module, $config = array())
{
parent::__construct($config);
$this->module = $module;
$this->tag = date('Ymd-His', microtime(true));
$this->tag = uniqid();
}
/**
......@@ -36,16 +39,32 @@ class LogTarget extends Target
*/
public function export()
{
$path = Yii::$app->getRuntimePath() . '/debug';
$path = $this->module->dataPath;
if (!is_dir($path)) {
mkdir($path);
}
$file = "$path/{$this->tag}.log";
$indexFile = "$path/index.json";
if (!is_file($indexFile)) {
$manifest = array();
} else {
$manifest = json_decode(file_get_contents($indexFile), true);
}
$request = Yii::$app->getRequest();
$manifest[$this->tag] = array(
'url' => $request->getAbsoluteUrl(),
'ajax' => $request->getIsAjax(),
'method' => $request->getMethod(),
'ip' => $request->getUserIP(),
'time' => time(),
);
$dataFile = "$path/{$this->tag}.json";
$data = array();
foreach ($this->module->panels as $panel) {
$data[$panel->id] = $panel->save();
foreach ($this->module->panels as $id => $panel) {
$data[$id] = $panel->save();
}
file_put_contents($file, json_encode($data));
file_put_contents($dataFile, json_encode($data));
file_put_contents($indexFile, json_encode($manifest));
}
/**
......@@ -58,36 +77,9 @@ class LogTarget extends Target
*/
public function collect($messages, $final)
{
$this->messages = array_merge($this->messages, $this->filterMessages($messages));
$this->messages = array_merge($this->messages, $messages);
if ($final) {
$this->export($this->messages);
$this->gc();
}
}
protected function gc()
{
if (mt_rand(0, 10000) > 100) {
return;
}
$iterator = new \DirectoryIterator(Yii::$app->getRuntimePath() . '/debug');
$files = array();
foreach ($iterator as $file) {
/** @var \DirectoryIterator $file */
if (preg_match('/^[\d\-]+\.log$/', $file->getFileName()) && $file->isFile()) {
$files[] = $file->getPathname();
}
}
sort($files);
if (count($files) > $this->historySize) {
$n = count($files) - $this->historySize;
foreach ($files as $i => $file) {
if ($i < $n) {
unlink($file);
} else {
break;
}
}
}
}
}
......@@ -28,27 +28,38 @@ class Module extends \yii\base\Module
public $controllerNamespace = 'yii\debug\controllers';
/**
* @var LogTarget
*/
public $logTarget;
/**
* @var array|Panel[]
*/
public $panels = array();
/**
* @var string the directory storing the debugger data files. This can be specified using a path alias.
*/
public $dataPath = '@runtime/debug';
public $historySize = 50;
public function init()
{
parent::init();
$this->dataPath = Yii::getAlias($this->dataPath);
$this->logTarget = Yii::$app->getLog()->targets['debug'] = new LogTarget($this);
Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar'));
foreach (array_merge($this->corePanels(), $this->panels) as $id => $config) {
$config['id'] = $id;
$config['module'] = $this;
$this->panels[$id] = Yii::createObject($config);
}
Yii::$app->getLog()->targets['debug'] = new LogTarget($this);
Yii::$app->getView()->on(View::EVENT_END_BODY, array($this, 'renderToolbar'));
}
public function beforeAction($action)
{
Yii::$app->getView()->off(View::EVENT_END_BODY, array($this, 'renderToolbar'));
unset(Yii::$app->getLog()->targets['debug']);
$this->logTarget = null;
$ip = Yii::$app->getRequest()->getUserIP();
foreach ($this->allowedIPs as $filter) {
......@@ -63,7 +74,7 @@ class Module extends \yii\base\Module
{
/** @var View $view */
$id = 'yii-debug-toolbar';
$tag = Yii::$app->getLog()->targets['debug']->tag;
$tag = $this->logTarget->tag;
$url = Yii::$app->getUrlManager()->createUrl('debug/default/toolbar', array(
'tag' => $tag,
));
......@@ -88,6 +99,12 @@ class Module extends \yii\base\Module
'log' => array(
'class' => 'yii\debug\panels\LogPanel',
),
'profiling' => array(
'class' => 'yii\debug\panels\ProfilingPanel',
),
'db' => array(
'class' => 'yii\debug\panels\DbPanel',
),
);
}
}
......@@ -15,7 +15,10 @@ use yii\base\Component;
*/
class Panel extends Component
{
public $id;
/**
* @var Module
*/
public $module;
public $data;
public function getName()
......
#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,16 +21,22 @@ class DefaultController extends Controller
public $module;
public $layout = 'main';
public function actionIndex($tag, $panel = null)
public function actionIndex($tag = null, $panel = null)
{
$this->loadData($tag);
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,
'meta' => $meta,
'manifest' => $this->getManifest(),
'panels' => $this->module->panels,
'activePanel' => $activePanel,
));
......@@ -45,19 +51,53 @@ class DefaultController extends Controller
));
}
public function actionPhpinfo()
{
phpinfo();
}
private $_manifest;
protected function getManifest()
{
if ($this->_manifest === null) {
$indexFile = $this->module->dataPath . '/index.json';
if (is_file($indexFile)) {
$this->_manifest = json_decode(file_get_contents($indexFile), true);
} else {
$this->_manifest = array();
}
if (count($this->_manifest) > $this->module->historySize) {
$n = count($this->_manifest) - $this->module->historySize;
foreach (array_keys($this->_manifest) as $tag) {
$file = $this->module->dataPath . "/$tag.json";
@unlink($file);
unset($this->_manifest[$tag]);
if (--$n <= 0) {
break;
}
}
file_put_contents($indexFile, json_encode($this->_manifest));
}
}
return $this->_manifest;
}
protected function loadData($tag)
{
$file = Yii::$app->getRuntimePath() . "/debug/$tag.log";
if (preg_match('/^[\w\-]+$/', $tag) && is_file($file)) {
$data = json_decode(file_get_contents($file), true);
$manifest = $this->getManifest();
if (isset($manifest[$tag])) {
$dataFile = $this->module->dataPath . "/$tag.json";
$data = json_decode(file_get_contents($dataFile), true);
foreach ($this->module->panels as $id => $panel) {
if (isset($data[$panel->id])) {
$panel->load($data[$panel->id]);
if (isset($data[$id])) {
$panel->load($data[$id]);
} else {
// remove the panel since it has not received any data
unset($this->module->panels[$id]);
}
}
return $manifest[$tag];
} else {
throw new HttpException(404, "Unable to find debug data tagged with '$tag'.");
}
......
......@@ -19,22 +19,64 @@ class ConfigPanel extends Panel
{
public function getName()
{
return 'Config';
return 'Configuration';
}
public function getSummary()
{
$yiiLogo = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB0AAAAeCAYAAADQBxWhAAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAH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AQADAgEAAwIBAAMCAQADAgEAAwIBAAMCAQADAgEAAwIBAAIAAAAAAQEBAAAAAAAAAAAA9/7/AAAAAACGRB0AAAQDAAD5/wAA/gEAAP4BAAAAAA4A/gAAAPr/AAD4/wAC+fwA+Pb4qfH7/jgDAgHjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT///8G/Pz8+gAAAAD///8AAgAAAPHt9wBCKBEAdFIfAMbZ7AARCwYADQkCAM7d9xzg6foABQ0D8SkVA7spHA+grNnxtfv8/gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAT9/f3+////AQQEBAEAAAABBAQE/f0BAQAABQcASiMNAN3g5wAbDQQADAf/AOgNAXosEgkMAQgAsA4GAe4SEAUA/P8BAAQBAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAP//vNz1LVdvDhUAAAAASUVORK5CYII=';
return <<<EOD
<div class="yii-debug-toolbar-block">
PHP: {$this->data['phpVersion']},
Yii: {$this->data['phpVersion']}
<a href="http://www.yiiframework.com/" title="Yii Framework">
<img width="29" height="30" alt="" src="$yiiLogo">
<span>{$this->data['application']['yii']}</span>
</a>
</div>
<div class="yii-debug-toolbar-block">
PHP {$this->data['php']['version']}
</div>
EOD;
}
public function getDetail()
{
return '<h2>Config</h2>';
$app = array(
'Yii Version' => $this->data['application']['yii'],
'Application Name' => $this->data['application']['name'],
'Environment' => $this->data['application']['env'],
'Debug Mode' => $this->data['application']['debug'] ? 'Yes' : 'No',
);
$php = array(
'PHP Version' => $this->data['php']['version'],
'Xdebug' => $this->data['php']['xdebug'] ? 'Enabled' : 'Disabled',
'APC' => $this->data['php']['apc'] ? 'Enabled' : 'Disabled',
'Memcache' => $this->data['php']['memcache'] ? 'Enabled' : 'Disabled',
);
return "<h1>Configuration</h1>\n"
. $this->renderData('Application Configuration', $app) . "\n"
. $this->renderData('PHP Configuration', $php) . "\n"
. '<div>' . Html::a('Complete phpinfo()', array('phpinfo'), array('class' => 'btn btn-info')) . "</div>\n";
}
protected function renderData($caption, $values)
{
if (empty($values)) {
return "<h3>$caption</h3>\n<p>Empty.</p>";
}
$rows = array();
foreach ($values as $name => $value) {
$rows[] = '<tr><th style="width: 200px;">' . Html::encode($name) . '</th><td><div style="overflow:auto">' . Html::encode($value) . '</div></td></tr>';
}
$rows = implode("\n", $rows);
return <<<EOD
<h3>$caption</h3>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead><tr><th style="width: 200px;">Name</th><th>Value</th></tr></thead>
<tbody>
$rows
</tbody>
</table>
EOD;
}
public function save()
......@@ -42,6 +84,18 @@ EOD;
return array(
'phpVersion' => PHP_VERSION,
'yiiVersion' => Yii::getVersion(),
'application' => array(
'yii' => Yii::getVersion(),
'name' => Yii::$app->name,
'env' => YII_ENV,
'debug' => YII_DEBUG,
),
'php' => array(
'version' => PHP_VERSION,
'xdebug' => extension_loaded('xdebug'),
'apc' => extension_loaded('apc'),
'memcache' => extension_loaded('memcache'),
),
);
}
}
<?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 DbPanel extends Panel
{
public function getName()
{
return 'Database';
}
}
......@@ -11,6 +11,7 @@ use Yii;
use yii\debug\Panel;
use yii\helpers\Html;
use yii\log\Logger;
use yii\log\Target;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
......@@ -25,12 +26,29 @@ class LogPanel extends Panel
public function getSummary()
{
$count = count($this->data['messages']);
return <<<EOD
$output = array();
$errorCount = count(Target::filterMessages($this->data['messages'], Logger::LEVEL_ERROR));
if ($errorCount === 1) {
$output[] = '1 error';
} elseif ($errorCount > 1) {
$output[] = "$errorCount errors";
}
$warningCount = count(Target::filterMessages($this->data['messages'], Logger::LEVEL_WARNING));
if ($warningCount === 1) {
$output[] = '1 warning';
} elseif ($warningCount > 1) {
$output[] = "$warningCount warnings";
}
if (!empty($output)) {
$log = implode(', ', $output);
return <<<EOD
<div class="yii-debug-toolbar-block">
Log messages: $count
$log
</div>
EOD;
} else {
return '';
}
}
public function getDetail()
......@@ -40,10 +58,21 @@ EOD;
$time = date('H:i:s.', $log[3]) . sprintf('%03d', (int)(($log[3] - (int)$log[3]) * 1000));
$level = Logger::getLevelName($log[1]);
$message = Html::encode(wordwrap($log[0]));
$rows[] = "<tr><td style=\"width: 100px;\">$time</td><td style=\"width: 100px;\">$level</td><td style=\"width: 250px;\">{$log[2]}</td><td>$message</td></tr>";
if ($log[1] == Logger::LEVEL_ERROR) {
$class = ' class="error"';
} elseif ($log[1] == Logger::LEVEL_WARNING) {
$class = ' class="warning"';
} elseif ($log[1] == Logger::LEVEL_INFO) {
$class = ' class="info"';
} else {
$class = '';
}
$rows[] = "<tr$class><td style=\"width: 100px;\">$time</td><td style=\"width: 100px;\">$level</td><td style=\"width: 250px;\">{$log[2]}</td><td>$message</td></tr>";
}
$rows = implode("\n", $rows);
return <<<EOD
<h1>Log Messages</h1>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead>
<tr>
......@@ -62,8 +91,10 @@ EOD;
public function save()
{
$target = $this->module->logTarget;
$messages = $target->filterMessages($target->messages, Logger::LEVEL_ERROR | Logger::LEVEL_INFO | Logger::LEVEL_WARNING | Logger::LEVEL_TRACE);
return array(
'messages' => Yii::$app->getLog()->targets['debug']->messages,
'messages' => $messages,
);
}
}
<?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;
use yii\log\Logger;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class ProfilingPanel extends Panel
{
public function getName()
{
return 'Profiling';
}
public function getDetail()
{
$messages = $this->data['messages'];
$timings = array();
$stack = array();
foreach ($messages as $i => $log) {
list($token, $level, $category, $timestamp) = $log;
$log[4] = $i;
if ($level == Logger::LEVEL_PROFILE_BEGIN) {
$stack[] = $log;
} elseif ($level == Logger::LEVEL_PROFILE_END) {
if (($last = array_pop($stack)) !== null && $last[0] === $token) {
$timings[$last[4]] = array(count($stack), $token, $category, $timestamp - $last[3]);
}
}
}
$now = microtime(true);
while (($last = array_pop($stack)) !== null) {
$delta = $now - $last[3];
$timings[$last[4]] = array(count($stack), $last[0], $last[2], $delta);
}
ksort($timings);
$rows = array();
foreach ($timings as $timing) {
$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 style=\"width: 80px;\">$time</td><td style=\"width: 220px;\">$category</td><td>$procedure</td>";
}
$rows = implode("\n", $rows);
return <<<EOD
<h1>Performance Profiling</h1>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead>
<tr>
<th style="width: 80px;">Time</th>
<th style="width: 220px;">Category</th>
<th>Procedure</th>
</tr>
</thead>
<tbody>
$rows
</tbody>
</table>
EOD;
}
public function save()
{
$target = $this->module->logTarget;
$messages = $target->filterMessages($target->messages, Logger::LEVEL_PROFILE);
return array(
'messages' => $messages,
);
}
}
......@@ -7,6 +7,8 @@
namespace yii\debug\panels;
use Yii;
use yii\base\InlineAction;
use yii\debug\Panel;
use yii\helpers\Html;
......@@ -23,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">
......@@ -39,37 +41,92 @@ EOD;
public function getDetail()
{
return "<h3>\$_GET</h3>\n" . $this->renderTable($this->data['GET']) . "\n"
. "<h3>\$_POST</h3>\n" . $this->renderTable($this->data['POST']) . "\n"
. "<h3>\$_COOKIE</h3>\n" . $this->renderTable($this->data['COOKIE']) . "\n"
. "<h3>\$_FILES</h3>\n" . $this->renderTable($this->data['FILES']) . "\n"
. "<h3>\$_SESSION</h3>\n" . $this->renderTable($this->data['SESSION']) . "\n"
. "<h3>\$_SERVER</h3>\n" . $this->renderTable($this->data['SERVER']);
$data = array(
'Route' => $this->data['route'],
'Action' => $this->data['action'],
'Parameters' => $this->data['actionParams'],
);
return "<h1>Request Information</h1>\n"
. $this->renderData('Routing', $data) . "\n"
. $this->renderData('Flashes', $this->data['flashes']) . "\n"
. $this->renderData('$_GET', $this->data['GET']) . "\n"
. $this->renderData('$_POST', $this->data['POST']) . "\n"
. $this->renderData('$_COOKIE', $this->data['COOKIE']) . "\n"
. $this->renderData('$_FILES', $this->data['FILES']) . "\n"
. $this->renderData('$_SESSION', $this->data['SESSION']) . "\n"
. $this->renderData('$_SERVER', $this->data['SERVER']) . "\n"
. $this->renderData('Request Headers', $this->data['requestHeaders']) . "\n"
. $this->renderData('Response Headers', $this->data['responseHeaders']);
}
public function save()
{
if (function_exists('apache_request_headers')) {
$requestHeaders = apache_request_headers();
} elseif (function_exists('http_get_request_headers')) {
$requestHeaders = http_get_request_headers();
} else {
$requestHeaders = array();
}
$responseHeaders = array();
foreach (headers_list() as $header) {
if (($pos = strpos($header, ':')) !== false) {
$name = substr($header, 0, $pos);
$value = trim(substr($header, $pos + 1));
if (isset($responseHeaders[$name])) {
if (!is_array($responseHeaders[$name])) {
$responseHeaders[$name] = array($responseHeaders[$name], $value);
} else {
$responseHeaders[$name][] = $value;
}
} else {
$responseHeaders[$name] = $value;
}
} else {
$responseHeaders[] = $header;
}
}
if (Yii::$app->requestedAction) {
if (Yii::$app->requestedAction instanceof InlineAction) {
$action = get_class(Yii::$app->requestedAction->controller) . '::' . Yii::$app->requestedAction->actionMethod . '()';
} else {
$action = get_class(Yii::$app->requestedAction) . '::run()';
}
} else {
$action = null;
}
/** @var \yii\web\Session $session */
$session = Yii::$app->getComponent('session', false);
return array(
'memory' => memory_get_peak_usage(),
'time' => microtime(true) - YII_BEGIN_TIME,
'SERVER' => $_SERVER,
'GET' => $_GET,
'POST' => $_POST,
'COOKIE' => $_COOKIE,
'flashes' => $session ? $session->getAllFlashes() : array(),
'requestHeaders' => $requestHeaders,
'responseHeaders' => $responseHeaders,
'route' => Yii::$app->requestedAction->getUniqueId(),
'action' => $action,
'actionParams' => Yii::$app->requestedParams,
'SERVER' => empty($_SERVER) ? array() : $_SERVER,
'GET' => empty($_GET) ? array() : $_GET,
'POST' => empty($_POST) ? array() : $_POST,
'COOKIE' => empty($_COOKIE) ? array() : $_COOKIE,
'FILES' => empty($_FILES) ? array() : $_FILES,
'SESSION' => empty($_SESSION) ? array() : $_SESSION,
);
}
protected function renderTable($values)
protected function renderData($caption, $values)
{
if (empty($values)) {
return "<h3>$caption</h3>\n<p>Empty.</p>";
}
$rows = array();
foreach ($values as $name => $value) {
$rows[] = '<tr><th style="width: 200px;">' . Html::encode($name) . '</th><td><div style="overflow:auto">' . Html::encode(var_export($value, true)) . '</div></td></tr>';
}
if (!empty($rows)) {
$rows = implode("\n", $rows);
return <<<EOD
$rows = implode("\n", $rows);
return <<<EOD
<h3>$caption</h3>
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead><tr><th style="width: 200px;">Name</th><th>Value</th></tr></thead>
<tbody>
......@@ -77,8 +134,5 @@ $rows
</tbody>
</table>
EOD;
} else {
return 'Empty.';
}
}
}
......@@ -4,16 +4,23 @@ use yii\helpers\Html;
/**
* @var \yii\base\View $this
* @var array $meta
* @var string $tag
* @var array $manifest
* @var \yii\debug\Panel[] $panels
* @var \yii\debug\Panel $activePanel
*/
$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>
......@@ -21,18 +28,39 @@ use yii\helpers\Html;
<div class="container-fluid">
<div class="row-fluid">
<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<ul class="nav nav-tabs nav-list nav-stacked">
<?php
foreach ($panels as $panel) {
$link = Html::a(Html::encode($panel->getName()), array('debug/default/index', 'tag' => $tag, 'panel' => $panel->id));
foreach ($panels as $id => $panel) {
$link = Html::a(Html::encode($panel->getName()), array('debug/default/index', 'tag' => $tag, 'panel' => $id));
echo Html::tag('li', $link, array('class' => $panel === $activePanel ? 'active' : null));
}
?>
</ul>
</div><!--/.well -->
</div><!--/span-->
<div class="span10">
<div class="meta alert alert-info">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
View others
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<?php foreach ($manifest as $tag2 => $meta2) {
$label = $meta2['method'] . ' ' . $meta2['url'] . ($meta2['ajax'] ? ' (AJAX)' : '')
. ', ' . date('Y/m/d h:i:sa', $meta2['time'])
. ', ' . $meta2['ip'] . ', ' . $tag2;
$url = array('debug/default/index', 'tag' => $tag2);
echo '<li>' . Html::a(Html::encode($label), $url) . '</li>';
} ?>
</ul>
</div>
Debugging:
<?php echo $meta['method']; ?>
<?php echo Html::a(Html::encode($meta['url']), $meta['url']); ?>
<?php echo $meta['ajax'] ? ' (AJAX)' : ''; ?>
at <?php echo date('Y/m/d h:i:sa', $meta['time']); ?>
by <?php echo $meta['ip']; ?>
</div>
<?php echo $activePanel->getDetail(); ?>
</div>
</div>
......
......@@ -12,17 +12,42 @@ 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>
......@@ -30,7 +55,4 @@ use yii\helpers\Html;
<?php foreach ($panels as $panel): ?>
<?php echo $panel->getSummary(); ?>
<?php endforeach; ?>
<div class="yii-debug-toolbar-block">
<?php echo Html::a('more details', array('index', 'tag' => $tag)); ?>
</div>
</div>
......@@ -5,7 +5,7 @@
*/
use yii\helpers\Html;
Yii::$app->getView()->registerAssetBundle('yii/bootstrap/responsive');
Yii::$app->getView()->registerAssetBundle('yii/debug');
?>
<!DOCTYPE html>
<html>
......
......@@ -855,7 +855,7 @@ class Html
* The signature of this callback must be:
*
* ~~~
* function ($index, $item)
* function ($item, $index)
* ~~~
*
* where $index is the array key corresponding to `$item` in `$items`. The callback should return
......@@ -876,7 +876,7 @@ class Html
$results = array();
foreach ($items as $index => $item) {
if ($formatter !== null) {
$results[] = call_user_func($formatter, $index, $item);
$results[] = call_user_func($formatter, $item, $index);
} else {
$results[] = static::tag('li', $encode ? static::encode($item) : $item, $itemOptions);
}
......@@ -897,7 +897,7 @@ class Html
* The signature of this callback must be:
*
* ~~~
* function ($index, $item)
* function ($item, $index)
* ~~~
*
* where $index is the array key corresponding to `$item` in `$items`. The callback should return
......
......@@ -161,7 +161,7 @@ class Logger extends Component
public function log($message, $level, $category = 'application')
{
$time = microtime(true);
if (YII_DEBUG && YII_TRACE_LEVEL > 0) {
if (YII_DEBUG && YII_TRACE_LEVEL > 0 && !($level & self::LEVEL_PROFILE)) {
$traces = debug_backtrace();
$count = 0;
foreach ($traces as $trace) {
......
......@@ -90,7 +90,7 @@ abstract class Target extends Component
*/
public function collect($messages, $final)
{
$this->messages = array_merge($this->messages, $this->filterMessages($messages));
$this->messages = array_merge($this->messages, $this->filterMessages($messages, $this->getLevels(), $this->categories, $this->except));
$count = count($this->messages);
if ($count > 0 && ($final || $this->exportInterval > 0 && $count >= $this->exportInterval)) {
if (($context = $this->getContextMessage()) !== '') {
......@@ -178,22 +178,22 @@ abstract class Target extends Component
/**
* Filters the given messages according to their categories and levels.
* @param array $messages messages to be filtered
* @param integer $levels the message levels to filter by. This is a bitmap of
* level values. Value 0 means allowing all levels.
* @param array $categories the message categories to filter by. If empty, it means all categories are allowed.
* @param array $except the message categories to exclude. If empty, it means all categories are allowed.
* @return array the filtered messages.
* @see filterByCategory
* @see filterByLevel
*/
protected function filterMessages($messages)
public static function filterMessages($messages, $levels = 0, $categories = array(), $except = array())
{
$levels = $this->getLevels();
foreach ($messages as $i => $message) {
if ($levels && !($levels & $message[1])) {
unset($messages[$i]);
continue;
}
$matched = empty($this->categories);
foreach ($this->categories as $category) {
$matched = empty($categories);
foreach ($categories as $category) {
if ($message[2] === $category || substr($category, -1) === '*' && strpos($message[2], rtrim($category, '*')) === 0) {
$matched = true;
break;
......@@ -201,7 +201,7 @@ abstract class Target extends Component
}
if ($matched) {
foreach ($this->except as $category) {
foreach ($except as $category) {
$prefix = rtrim($category, '*');
if (strpos($message[2], $prefix) === 0 && ($message[2] === $category || $prefix !== $category)) {
$matched = false;
......
......@@ -65,6 +65,8 @@ class Application extends \yii\base\Application
$params = array_splice($this->catchAll, 1);
}
try {
Yii::trace("Route requested: '$route'", __METHOD__);
$this->requestedRoute = $route;
$result = $this->runAction($route, $params);
if ($result instanceof Response) {
return $result;
......
......@@ -177,7 +177,7 @@ class CaptchaAction extends Action
$session->open();
$name = $this->getSessionKey() . 'count';
$session[$name] = $session[$name] + 1;
if ($session[$name] > $this->testLimit && $this->testLimit > 0) {
if ($valid || $session[$name] > $this->testLimit && $this->testLimit > 0) {
$this->getVerifyCode(true);
}
return $valid;
......
......@@ -171,6 +171,7 @@ class UrlManager extends Component
/** @var $rule UrlRule */
foreach ($this->rules as $rule) {
if (($result = $rule->parseRequest($this, $request)) !== false) {
Yii::info("Request parsed with URL rule: {$rule->name}", __METHOD__);
return $result;
}
}
......@@ -194,12 +195,14 @@ class UrlManager extends Component
}
}
Yii::info('No matching URL rules. Using default URL parsing logic.', __METHOD__);
return array($pathInfo, array());
} else {
$route = $request->get($this->routeVar);
if (is_array($route)) {
$route = '';
}
Yii::info('Pretty URL not enabled. Using default URL parsing logic.', __METHOD__);
return array((string)$route, array());
}
}
......
......@@ -388,7 +388,7 @@ EOD;
EOD;
$this->assertEqualsWithoutLE($expected, Html::ul($data, array(
'class' => 'test',
'item' => function($index, $item) {
'item' => function($item, $index) {
return "<li class=\"item-$index\">$item</li>";
}
)));
......@@ -418,7 +418,7 @@ EOD;
EOD;
$this->assertEqualsWithoutLE($expected, Html::ol($data, array(
'class' => 'test',
'item' => function($index, $item) {
'item' => function($item, $index) {
return "<li class=\"item-$index\">$item</li>";
}
)));
......
......@@ -7,6 +7,12 @@ use yiiunit\TestCase;
class UrlManagerTest extends TestCase
{
protected function setUp()
{
parent::setUp();
$this->mockApplication();
}
public function testCreateUrl()
{
// default setting with '/' as base url
......
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