yii如何使用CWebLogRoute记录和调试变量routedeleterouteadddefaultgwlinuxroutead
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了yii如何使用CWebLogRoute记录和调试变量routedeleterouteadddefaultgwlinuxroutead,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1818字,纯文字阅读大概需要3分钟。
内容图文
![yii如何使用CWebLogRoute记录和调试变量routedeleterouteadddefaultgwlinuxroutead](/upload/InfoBanner/zyjiaocheng/160/91274eb3db044bd0af7e37154288523e.jpg)
我看了几遍关于使用外部库来调试PHP代码(如: firePHP)的文章, 读了这篇文章你会发现在 Yii 中没有必要使用这些外部库.
Yii 内置了强大的日志记录类. 如果你阅读了记录日志的文档, 你可以发现我们可以决定我们希望记录的日志, 这正是我们要做的,使用 CWebLogRoute 创建一个 Yii 版本的 FirePHP.
配置
在我们的 protected/config/main.php 配置文件中添加配置:
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CWebLogRoute',
//// I include *trace* for the// sake of the example, you can include//// more levels separated by commas'levels'=>'trace',
//// I include *vardump* but you// can include more separated by commas'categories'=>'application.*,system.db.*,vardump',
//// This is self-explanatory right?'showInFireBug'=>true ),
),
),
使用
准备完毕,现在让我们来追踪一下变量来测试一下, 如下:
publicfunctionactionTrace(){$test = 'This is a test';
$anotherTest = array('one','two','three');
echo Yii::trace(CVarDumper::dumpAsString($test),'vardump');
echo Yii::trace(CVarDumper::dumpAsString($anotherTest),'vardump');
echo Yii::trace(CVarDumper::dumpAsString($this),'vardump');
}
Yii 的 FirePHP 函数
上面的代码写起来比较长, 我们来使用一下 强的建议, 让我在 index.php 页面写一个像 FirePHP 函数:
publicfunctionactionTrace()
{//// In your index.php or your globals.php filefunctionfb($what)
{echo Yii::trace(CVarDumper::dumpAsString($what), 'vardump');
}
// // using the above examples now we could$test = 'This is a test';
fb($test);
}
OK, 全部完成了,我们的调试器中没有使用外部的类.
补充
此方法无需安装chromephp 插件,firebug浏览器均可使用,opera,chrome,firefox等都适用。
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('').text(i)); }; $numbering.fadeIn(1700); }); });以上就介绍了yii 如何使用 CWebLogRoute 记录和调试变量,包括了route,eblog方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
内容总结
以上是互联网集市为您收集整理的yii如何使用CWebLogRoute记录和调试变量routedeleterouteadddefaultgwlinuxroutead全部内容,希望文章能够帮你解决yii如何使用CWebLogRoute记录和调试变量routedeleterouteadddefaultgwlinuxroutead所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。