目錄
- 創建 DBGP 服務
- 配置
如果已經有人配置好,其他人如果也想要調試的話,只需按照這里的 2 和 3 配置。 - 調試
創建 DBGP 服務
到 下載頁面,下載 python 版本的 dbgp 到服務器上。
解壓后執行 pydbgpproxy。
如果提示找不到 dbgp 模塊,則編輯該文件。在 96 行左右有這么一塊代碼:
candidate_paths = [ dirname(this_dir), # Komodo source tree layout join(dirname(this_dir), pythonlib), ]
把
join(dirname(this_dir), pythonlib)
改為join(this_dir, pythonlib)
再執行。如果執行成功,會有類似於以下的輸出:
[root@localhost dbgp]# ./pydbgpproxy -i 0.0.0.0:9001 -d 9000 INFO: dbgp.proxy: starting proxy listeners. appid: 11203 INFO: dbgp.proxy: dbgp listener on 127.0.0.1:9000 INFO: dbgp.proxy: IDE listener on 0.0.0.0:9001
配置
服務器上編輯 php.ini
修改以下兩個配置:xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000
如果沒有裝 Xdebug 插件,請先安裝。
PHPstorm 上設置
IDE key 設置為任意字符串(不能與其他人重復),填寫自己名字拼音就行了。
Host 填服務器的 ip
Port 填 9001開始監聽 debug(下一步之前必須保證已經開啟監聽,否則無效):
如果 dgbp 服務已打開,就可以注冊了
Tools | DBGp Proxy | Register IDEchrome 瀏覽器上配置
進入 chrome 商店,搜索 Xdebug helper。安裝完畢后,右鍵 Xdebug helper,選擇 選項 進入配置。IDE key 選 Other,在右邊填入剛才在 PHPstorm 上設置的 IDE key。點 Save 保存。
調試
開始打斷點調試吧~刷新頁面或者點擊按鈕觸發請求,一旦有執行到打斷點的那一行,就會停下來。
參考:
Multi-user debugging in PhpStorm with Xdebug and DBGp proxy