strider2038 / yii2-ajax-debugger
此包已被弃用且不再维护。未建议替代包。
方便的开发者工具,用于在浏览器中调试AJAX请求
1.0.0
2017-02-26 20:52 UTC
Requires
- bower-asset/json-beautify-it: 1.*
- yiisoft/yii2: *
This package is auto-updated.
Last update: 2022-02-01 13:05:42 UTC
README
安装
运行以下命令之一
$ php composer.phar require strider2038/yii2-ajax-debugger "*"
或将以下内容添加到您的composer.json
文件的require
部分。
"strider2038/yii2-ajax-debugger": "*"
关于
此工具基于JSONBeautifyIt函数,用于格式化JSON/JSONP数据。DebugDetector组件可以拦截来自服务器的JSON或JSONP响应并将其格式化为HTML文档。在渲染JSON数据后,会应用JSONBeautifyIt函数来美化渲染的数据数组。请注意,在生产模式下使用此组件。
要设置此组件以工作,您应将这些行添加到您的web配置文件中
$config = [ // this is needed to initialize component on app load 'bootstrap' => ['ajaxDebugger', ...], 'components' => [ 'ajaxDebugger' => [ 'class' => 'strider2038\ajaxdebugger\DebugDetector', // conditions for enabling debug mode 'enabled' => YII_ENV_DEV && !empty($_GET['_debug']), ], ... ], ... ];
之后,您可以在浏览器中打开带有AJAX或API响应的页面。如果您添加GET参数 _debug=1,您将看到解析后的JSON数据和调试面板,就像在其他HTML页面中一样。
您可以在我的Yii2模板中看到工作示例 - https://github.com/strider2038/yii2-template/blob/master/controllers/AjaxController.php