Zhanhailiang Date: 2014-10-28
PHP console:https://github.com/barbushin/php-console#php-console-server-library
function Introduction
PHP Console tools and firephp functions are similar , provides the following features:
Handle PHP errors, dump variables, execute PHP code remotely in Google Chrome
Demo
First install the PHP console plugin in chrome:
Https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
Next, the PHP console library is introduced into the PHP code, and the corresponding debug information is called out:
The following example index2.php:
<?phprequire_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 ');
Output debugging information to the console, such as:
Principle Introduction
The PHP console tool outputs debug information by outputting Debug information to the HTTP response header Php-console, and then the PHP console plug-in parses the response header Php-console string.
Appendix
PHP Console provides the ability to protect debug information through a password, as in the following example, setting a password on the server side:
<?phprequire_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 ');
At this point you can see that only when the client enters the correct password:
The response header does not output the appropriate debug information at this time:
http/1.1 okserver:tengine/2.0.3date:tue, Oct 12:36:04 Gmtcontent-type:text/htmlconnection:keep-alivex-pow Ered-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
Use the PHP console tool to share