PHP Console工具使用分享
来源:互联网 发布:tgp腾讯游戏客户端mac 编辑:程序博客网 时间:2024/06/13 18:05
作者:zhanhailiang 日期:2014-10-28
PHP Console:https://github.com/barbushin/php-console#php-console-server-library
功能介绍
PHP Console工具和FirePHP功能相似,提供以下功能:
Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
Demo
首先在Chrome中安装PHP Console插件:
https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
其次在PHP代码中引入PHP Console库,然后调用输出相应调试信息:
如下例index2.php:
<?php require_once(__DIR__ . '/../src/PhpConsole/__autoload.php'); // Call debug from PhpConsole\Handler$handler = PhpConsole\Handler::getInstance();$handler->start();$handler->debug('called from handler debug', 'some.three.tags'); $array = array( 'test' => 1, 'test2' => 1, 'key' => array( 1, 2, 3, 4, ), );$handler->debug($array, 'test.wiki.wade.zhan');
输出调试信息到控制台,如下图:
原理介绍
PHP Console工具通过将调试信息输出到http响应头PHP-Console,然后PHP Console插件分析响应头PHP-Console字符串输出相应调试信息。
附录
PHP Console提供了通过密码来保护调试信息的功能,如下例,在服务器端设置密码:
<?php require_once(__DIR__ . '/../src/PhpConsole/__autoload.php'); $password = 'test';$connector = PhpConsole\Connector::getInstance();$connector->setPassword($password); // Call debug from PhpConsole\Handler$handler = PhpConsole\Handler::getInstance();$handler->start();$handler->debug('called from handler debug', 'some.three.tags'); $array = array( 'test' => 1, 'test2' => 1, 'key' => array( 1, 2, 3, 4, ), );$handler->debug($array, 'test.wiki.wade.zhan');
此时可以看到只有当客户端输入正确的密码:
此时响应头部才会输出相应的调试信息:
HTTP/1.1 200 OKServer: Tengine/2.0.3Date: Tue, 28 Oct 2014 12:36:04 GMTContent-Type: text/htmlConnection: keep-aliveX-Powered-By: PHP/5.3.29PHP-Console-Postpone: {"protocol":5,"isPostponed":true,"id":"6957661441226218549514727634"}PHP-Console: {"protocol":5,"auth":{"publicKey":"bf802ef9f6d61a5d4a720892a79bf8285d92c31c2a99be2931b504dc54eeb209","isSuccess":true},"docRoot":"\/usr\/local\/wwwroot\/dokuwiki","sourcesBasePath":null,"getBackData":null,"isLocal":false,"isSslOnlyMode":false,"isEvalEnabled":false,"messages":[{"type":"debug","tags":["some","three","tags"],"data":"called from handler debug","file":null,"line":null,"trace":null},{"type":"debug","tags":["test","wiki","wade","zhan"],"data":{"test":1,"test2":1,"key":[1,2,3,4]},"file":null,"line":null,"trace":null}]}Content-Length: 0
1 0
- PHP Console工具使用分享
- PHP开发调试(debug)工具Eclipse Console for PHP(EC4P)
- 【PHP分享】Windows tail工具分享
- php使用分享(一)
- Clusterware Console脚本分享
- 使用cocos2d-console工具转换脚本为字节码
- console使用
- 验证码工具分享-PHP识别工具SECURIMAGE
- chrome开发者工具console
- php持续集成工具:xinc中web界面配置分享
- 分享几款一键搭建php本地测试环境工具
- 分享一段PHP制作的中文拼音首字母工具类
- 分享几款一键搭建php本地测试环境工具
- Advanced PHP Programming -- 如何理解 Console/Getopt.php 的使用 P129
- PHP缓存技术的使用技巧分享
- PHP函数mb_strcut的使用技巧分享
- 分享PHP header函数使用教程
- php使用百度翻译api示例分享
- POJ 1002 487-3279
- Servlet的一些重要细节
- iOS多线程GCD
- 电容的充电速率
- 高级控件:菜单、工具栏多窗口控制
- PHP Console工具使用分享
- MongoDB之整库备份还原单表collection备份还原
- 数据结构基础java实现—双向链表
- poj3009 冰球
- Android:圆形头像
- HDU1162最小生成树
- 网页宽度自动调整响应式网页
- 结合属性文件的工厂模式(java反射的应用)
- mysql 数据库导入导出方法总结(是时候总结)