Use the PHP console tool to share

Source: Internet
Author: User

  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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.