1, 下載 Xdebug
1 | # 下載地址 |
2 | #http://xdebug.org/download.php |
3 |
4 | # 尋找和自己所安裝的 php 版本對應的 Xdebug 下載 |
5 | # 對于 Windows 版本的 php 可以查看 phpinfo() 函數的打印信息, 查找"PHP Extension Build", 看你的 PHP 版本是 VC 幾的, |
2, 安裝
1 | # 安裝說明頁 |
2 | #http://xdebug.org/docs/install |
3 |
4 | # 對于 Windows 版本, 下載完成后將下載的 dll 文件重命名為 php_xdebug.dll |
5 | # 將其復制到 PHP 的擴展目錄中去 (例如: D:/PRogram Files/EasyPHP-5.3.2i/php/ext/ ) |
3, 修改 php.ini
01 | # 在 php.ini 尾部增加一段, 改完之后重啟 Web-Server |
02 | [Xdebug] |
03 | zend_extension= "D:/Program Files/EasyPHP-5.3.2i/php/ext/php_xdebug.dll" |
04 |
05 | xdebug.profiler_enable=on |
06 | xdebug.trace_output_dir= "E:/xdebug" ;xdebug 的數據文件目錄 |
07 | xdebug.profiler_output_dir= "E:/xdebug" ;xdebug 的數據文件目錄 |
08 | xdebug.max_nesting_level = 10000 ;如果設得太小,函數中有遞歸調用自身次數太多時會報超過最大嵌套數錯 |
09 |
10 | xdebug.remote_enable= true ;Xdebug允許遠程IDE連接 |
11 | xdebug.remote_host=127.0.0.1 ;允許連接的zend studio的ip地址 |
12 | xdebug.remote_port=9000 ;反向連接zend studio使用的端口 |
13 | xdebug.remote_handler=dbgp ;用于zend studio遠程調試的應用層通信協議 |
4, 修改 Zend Studio 設置
1 | Window -> Preferences -> PHP -> Debug |
2 | # 將左側 "Default Settings" 中的 "PHP Debugger" 設置為 "XDebug" |
5, 在項目中新建一個 test.php 文件
view sourceprint?1 | <?php |
2 | for ( $i = 0; $i < 10; $i ++) { |
3 |
if ( $i ==5) { |
4 |
echo 'aa' ; |
5 |
} |
6 | } |
7 | ?> |
6, 新建一個 Debug 命令
1 | # 點擊工具欄上"小蜘蛛"旁邊的小箭頭 -> Debug As -> PHP Web Page |
2 | # 會跳出 Debug 視圖 |
3 | # 在 "if ($i==5) {" 這一行前面加一個斷點, 就可以進行單步調試了 |
新聞熱點
疑難解答