Use PHPConsole to share
Author: zhanhailiang date:
PHP Console: https://github.com/barbushin/php-console#php-console-server-library
Features
The PHP Console tool and FirePHP have similar functions., Provides the following features:
Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
Demo
First install the PHP Console plug-in Chrome:
Https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
Next, introduce the PHP Console library in the PHP code, and then call and output the corresponding debugging information:
For example, index2.php:
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 ');
Output debugging information to the console, such:
Principles
The PHP Console tool outputs debugging information to the http response header PHP-Console, and then the PHP Console plug-in analyzes the response header PHP-Console string to output the corresponding debugging information.
Appendix
The PHP Console provides a password to protect debugging information. for example, set a password on the server:
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 ');
At this point, we can see that only when the client enters the correct password:
At this time, the response header will output the corresponding debugging information:
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": "success", "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, 4]}, "file": null, "line": null, "trace": null}]} Content-Length: 0