2017-03-16 113 views
0

我試圖配置Xdebug與Sublime Text 3一起使用,但是我無法在Context,Watch或Stack選項卡中顯示任何內容,例如通過設置斷點並點擊開始調試(啓動瀏覽器)。瀏覽器將?XDEBUG_SESSION_START=sublime.xdebug附加到url打開index.php文件,但在達到斷點時不會停止執行代碼。爲Sublime3配置Xdebug(PHP)path_mapping和php.ini

我也嘗試添加xdebug_break()到index.php沒有任何效果。

從我讀過的文檔中,在.sublime-project文件中指定path_mapping似乎是最有可能的解決方案。該documentation指出:

path_mapping

用於遠程調試來解決它配置有作爲的價值關鍵和本地路徑服務器路徑的路徑映射需要的文件位置。

我使用Windows 10,應用程序的文件存儲在C:\inetpub\wwwroot\ IIS和網頁的網址是http://localhost/index.php這我假設是服務器的路徑,並分別本地路徑,因此在.sublime-project文件看起來像這樣:

{ 
    "folders": 
    [ 
     { 
      "path": "." 
     } 
    ], 
    "settings": { 
     "xdebug": { 
      "url": "http://localhost/index.php", 
      "path_mapping" : {"C:\\inetpub\\wwwroot\\" : "http://localhost/index.php"} 
     } 
    } 
} 

這是正確的嗎?如果是,我的php.ini文件配置是否正確?

[ExtensionList] 
. 
. 
. 
zend_extension = "C:\Program Files (x86)\PHP\php-5.6.30-nts-Win32-VC11-x86\ext\php_xdebug-2.5.1-5.6-vc11-nts.dll" 

[XDEBUG] 
xdebug.default_enable=1 
xdebug.remote_autostart=0 
xdebug.remote_connect_back=1 
xdebug.remote_enable=1 
xdebug.remote_handler=dbgp 
xdebug.remote_port=9000 
xdebug.remote_host=localhost 
+1

*「我假設它們分別是服務器路徑和本地路徑」* NO - 它與URL無關。當遠程**文件路徑**與本地路徑不匹配時,需要使用路徑映射。在本地計算機網站上,'index.php'位於'/ var/www /'中,但遠程位於'/ var/www/html/site-name /'中。收集xdebug日誌以查看發生了什麼。 – LazyOne

+0

非常感謝@LazyOne問題現在已經在您的評論幫助下解決了。 – gbavba

回答

0

path_mapping的php.ini設置都是不正確。

基於@ LazyOne的評論,在.sublime-project文件中刪除不正確的path_mapping所以現在看起來是這樣的:

{ 
    "folders": 
    [ 
     { 
      "path": "." 
     } 
    ], 
    "settings": { 
     "xdebug": { 
      "url": "http://localhost/index.php" 
     } 
    } 
} 

然後加入xdebug.remote_log="C:\Windows\Temp\Xdebug\remote.log"的php.ini和檢查日誌顯示:

I: Remote address found, connecting to ::1:9000. 
E: Time-out connecting to client. :-(

搜索此錯誤導致@ Axel回答此問題SO question並基於此,將xdebug.remote_connect_back=1更改爲xdebug.remote_connect_back=0php.ini中

斷點,然後開始工作和語境觀看堆棧標籤開始出現在到達它們的相關數據。

+0

所以問題是Sublime中的xdebug支持不支持IPv6 ..所以它必須是IPv4?成功的會話如何在xdebug日誌中查找?我的意思是 - 它可以連接到什麼IP:端口? – LazyOne

+0

'localhost:9000'日誌顯示'I:連接到配置的地址/端口:localhost:9000.'然後'I:連接到客戶端。 :-)' – gbavba