本来我一直用Krumo的,但是Krumo对中文支持不好,同时在Yii架构中引入Krumo感觉不伦不类的。偶然发现Yii中有一个拓展Kint可以代替Krumo,就界面和调用的简便性而言,超越Krumo不在话下。
首先去http://www.yiiframework.com/extension/kint/下载最新版的Kint拓展,然后解压到protected/extensions目录下。接下来我们写几句配置语句让Yii知道我们新加入了Kint拓展:
config (main.php) 的 components数组中加入:
'kint' => array(
'class' => 'ext.Kint.Kint',
),
preload数组中预加载:
'preload' => array('log', 'kint'),
预加载的作用是使用简短的函数名d($variable);而非老长老长的Kint::dump($variable);。好了到此就可以享受Kint的便捷Debug了,比如在SiteController的public function actionIndex()中试一试:
public function actionIndex()
{
// renders the view file 'protected/views/site/index.php'
// using the default layout 'protected/views/layouts/main.php'
d($this);
$this->render('index');
}
直接将整个SiteController打印在了页面上:

而如果你使用dd的话,整个webapp会终止在这一行。s函数是简单的不带css和js的dump。
码农场