Yii2-debug 在特定页面开启调试
2018-01-29 10:08
375 查看
debug调试器,是简单的bug收集工具,在调试问题的时候非常有用。 但是当上线了之后,有两种方法来进行调试 1、制定特定的ip 在allowedIPs中加入当前网络的ip,这样就可以只有当前网络可见了,这是最常用也是最好的调试方式
$config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', // uncomment the following to add your IP if you are not connecting from localhost. 'allowedIPs' => ['127.0.0.1', '::1'], ];2、只允许特定页面进行显示
(1)首先页面要开启debug
$config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class' => 'yii\debug\Module', // uncomment the following to add your IP if you are not connecting from localhost. 'allowedIPs' => ['127.0.0.1', '::1'], ];
(2)在commen/libs中定义开始或者关闭的工具类[/code]
namespace common\libs; use Yii; class Tools { public static function DebugToolbarOff(){ if(class_exists('\yii\debug\module')){ Yii::$app->view->off(\yii\web\View::EVENT_END_BODY,[yii\debug\Module::getInstance(),'renderToolbar']); } } public static function DebugToolbarOn(){ if (class_exists('\yii\debug\module')){ Yii::$app->view->on(yii\web\View::EVENT_END_BODY,[yii\debug\Module::getInstance(),'renderToolbar']); } } }
(3)在所有的页面禁用debug 在继承的controller中取消
public function __construct($id, $module, $config = []) { Tools::DebugToolbarOff(); parent::__construct($config); }
(4)在要显示的页面开启debug
public function actionAdd () { Tools::DebugToolbarOn(); ... }
查看原文:http://www.architecy.com/archives/397
相关文章推荐
- 在Yii2特定页面如何禁用调试工具栏Debug Toolbar详解
- u-boot 2011.09 开启debug 调试
- zend studio for eclipse 设置及 debug 页面跳转调试
- zend studio for eclipse 设置及 debug 页面跳转调试
- 【discuz x3】如何开启discuz x3的debug调试功能
- 网站后端_Python+Flask.0005.FLASK调试模式之开启DEBUG与PIN使用?
- 【yii2调试神器】yii2-debug能力分析和配置项解析
- Win7下WinDbg开启Local Kernel Debug调试
- flask如何通过不使用debug=True,通过使用config开启调试模式
- VS 属性页面中Debug、Realease多线程调试
- YII 1 开启调试模式以及导入第三方调试插件yii-debug-toolbar
- Win7下WinDbg开启Local Kernel Debug调试
- struts项目中jsp页面调试方法---debug标签
- 调试openfire的JSP页面,openfire debug
- 前端页面debug调试
- yii2 表单提交一直报错 或者页面脚本写ajax,用firbug调试总是找不到地址页面404
- 【discuz x3】如何开启discuz x3的debug调试功能
- maven+jetty工程开启Debug调试
- Myeclipse中启动tomcat服务就进入调试(debug)页面
- 微信分享——开启debug调试,调试提示正常,分享没有标题和图片