PHPコンソール:https://github.com/barbushin/php-console#php-console-server-library
特徴
PHPコンソールツールにはFirePHPと同様の機能があり、次の機能を提供します。
PHPエラーの処理、変数のダンプ、GoogleChromeでのPHPコードのリモート実行
デモ
まず、ChromeにPHPコンソールプラグインをインストールします。
https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef
次に、PHPコンソールライブラリをPHPコードに導入し、を呼び出して対応するデバッグ情報を出力します。
次の例のindex2.php:
<?php require_once(__ DIR __。 '/ .. / src / PhpConsole / __ autoload.php'); // PhpConsole \ Handler $ handler = PhpConsole \ Handler :: getInstance(); $ handler-> start(); $ handler-> debug( '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コンソールツールはデバッグ情報をHTTP応答ヘッダーPHP-Consoleに出力し、次にPHPコンソールプラグインが応答ヘッダーPHP-Console文字列を分析して対応するデバッグ情報を出力します。
付録
PHPコンソールは、デバッグ情報をパスワードで保護する機能を提供します。次の例では、サーバー側でパスワードを設定します。
<?php require_once(__ DIR __。 '/ .. / src / PhpConsole / __ autoload.php'); $ password = 'test'; $ Connector = PhpConsole \ Connector :: getInstance(); $ Connector-> setPassword($ password); // PhpConsole \ Handler $ handler = PhpConsole \ Handler :: getInstance(); $ handler-> start(); $ handler-> debug( '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 OK サーバー:Tengine / 2 。0。3 日付:2014年10月28日火曜日12:36:04 GMT コンテンツタイプ:text / html 接続:keep-alive X-Powered-By:PHP / 5.3.29 PHP- Console-延期:{"protocol":5、 "isPostponed":true、 "id": "6957661441226218549514727634"} PHP-コンソール:{"protocol":5、 "auth":{"publicKey": "bf802ef9f6d61a5d4a720892a79bf8285d92c31c2a99be2931b504dc54eeb209"、 "isSuccess":true}、 "docRoot": "\ / usr \ / local \ / wwwroot \ / "sourcesBasePath":null、 "getBackData":null、 "isLocal":false、 "isSslOnlyMode":false、 "isEvalEnabled":false、 "messages":[{"type": "debug"、 "tags":[" some "、" three "、" tags "]、" data ":"ハンドラーから呼び出されました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