前置環境:已經安裝好LNMP
1. 安裝xdebug
可以通過pear包管理來安裝
sudo apt-get install php-pear
sudo pecl install xdebug
這裡我們直接通過apt安裝
apt-get install php5-xdebug
程式已經自動建立了預設的設定檔
配置:
xdebug.ini位置:/etc/php5/mods-available/xdebug.ini
新增如下
zend_extension="/usr/lib/php5/20131226/xdebug.so"
xdebug.profiler_output_dir=/tmp
xdebug.profiler_output_name=cachegrind.out.%p
xdebug.profiler_enable_trigger=1
xdebug.profiler_enable=true
xdebug.remote_enable=true
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode = req
xdebug.remote_connect_back = 1
xdebug.remote_autostart=0
xdebug.collect_vars = On
xdebug.collect_params = On
xdebug.auto_trace = On
xdebug.show_exception_trace = On
xdebug.trace_output_dir=/tmp
重啟PHP5-FPM
/etc/init.d/php5-fpm restart
2. 開啟調試
sublime 中 CRL+ALT+F9 開啟調試介面
查看連接埠 9000
3.測試
建立檔案test.php
for ($i=0; $i < 10; $i++) {
echo $i;
}
?>
在瀏覽器裡訪問 http://127.0.0.1/test.php
可以看到我們斷點的地方 $i = 0
Shift+f8: 開啟調試面板
f8:開啟調試面板快速串連
Ctrl+f8: 切換斷點
Ctrl+Shift+f5: 運行到下一個斷點
Ctrl+Shift+f6: 單步
Ctrl+Shift+f7: 步入
Ctrl+Shift+f8: 步出
CTRL+SHIFT+F7
本文地址:http://www.cnblogs.com/martin-tan/p/4921200.html
PHP X-Debug的檔案
UBUNTU下面有KCachegrind直接開啟,方便trace檔案載入順序
以上就介紹了PHP XDebug Sublime Text 單步調試,包括了方面的內容,希望對PHP教程有興趣的朋友有所協助。