PHP Console工具使用分享,phpconsole

來源:互聯網
上載者:User

PHP Console工具使用分享,phpconsole

  作者: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


怎在windows下擁有php console - 技術問答

看了樓上提供的了,沒有用,找到php.exe了,但是執行了沒有用啊有哪位裝了wamp的,可以在windows下,在command line下運行php的啊?請問你是怎麼配置的?
 
jquery有沒有調試工具,就像PHP中一樣,出錯了可以提示第幾行,什錯誤類型的?

你可以用firefox瀏覽器,有錯誤控制台。可以提示那一段js代碼有誤。 每次測試頁面的時候,如果有js代碼錯誤或者警告可以從錯誤控制台看到。
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.