2017-05-04 203 views
0

我已經安裝了VS代碼PHP調試器visual studio code PHP調試不起作用

我正在使用xampp。

我試着運行代碼(2)方式(偵聽和啓動)。

只是坐在那裏,而啓動顯示產卵PHP ENOENT在調試控制檯。

這是我的launch.json。

{ 
    "version": "0.2.0", 
    "configurations": [ 

     { 
      "name": "Listen for XDebug", 
      "type": "php", 
      "request": "launch", 
      "port": 9000 
     }, 
     { 
      "name": "Launch currently open script", 
      "type": "php", 
      "request": "launch", 
      "program": "${file}", 
      "cwd": "${fileDirname}", 
      "port": 9000 
     } 
    ] 
} 

我在做什麼錯?

+0

您是否在php.ini中啓用遠程調試? –

+0

你的問題是什麼?對我來說似乎還不清楚。 – Jer

+0

[了XDebug] 的zend_extension = 「php_xdebug-2.5.3-5.5-VC11-nts.dll」 ; xdebug.profiler_append = 0 ; xdebug.profiler_enable = 1 ; xdebug.profiler_enable_trigger = 0 ; xdebug.profiler_output_dir =「 C:\ XAMPP \ TMP」 ; xdebug.profiler_output_name = 「cachegrind.out%叔%S」 xdebug.remote_enable = 1 xdebug.remote_autostart = 1 xdebug.remote_handler = 「dbgp」 xdebug.remote_host =本地主機 xdebug.remote_port = 9000 xdebug.trace_output_dir =「C:\ xampp \ tmp」 – GaryK4

回答

0

您是否檢查過以確保防火牆允許端口9000上的入站連接?我在我的一臺開發機器上遇到了這個確切的問題。雖然所有其他設置都是正確的,但我無法擊中這些折點。一旦我在防火牆中添加了一個異常,它就開始工作。

所以如果這是你的設置的問題,你有兩個選項來解決它。

  1. 完全關閉您的防火牆,或者至少暫時關閉您的項目。
  2. 添加一個例外,你的防火牆設置:
    • 轉到Windows控制面板,然後鍵入「防火牆」。
    • 從左側導航欄中選擇「入站規則」,然後單擊「新規則」。
    • 選擇「端口」,然後點擊「下一步」。
    • 確保選擇了「特定本地端口」選項併爲端口號鍵入「9000」。
    • 選擇「允許連接」,然後點擊「下一步」。
    • 選中「域名」,「私人」和「公共」,然後點擊「下一步」。
    • 輸入一個描述性名稱,如「XDebug Port」,然後點擊「完成」。
    • 重新啓動Visual Studio代碼,然後再次嘗試調試。

假設你有配置設置的Web服務器部分正確這應該讓你調試。

希望這會有所幫助。

0

剛纔所說的:

  1. 我們有操作系統Windows與Microsoft Visual代碼,我們已經安裝了「PHP調試」模塊https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug#overview措施,讓工作已經羅滕這裏,但我再次寫入:

  2. 安裝XDebug。在線嚮導https://xdebug.org/wizard.php可以幫助你,只需在這裏發佈phpinfo()數據。保存在phpinfo.php的是:

    <?php phpinfo(); ?> 
    

然後在瀏覽器本地主機/ phpinfo.php的開放,複製你看到(CTRL + A,然後Ctrl + C),以嚮導的一切。它顯示了所獲得的信息和步驟做: enter image description here

在指令php.ini中所示( 總是有許多的php.ini
  • 打開- apache的文件夾具有一個PHP .ini,php有php.ini和phpForApache.ini,但phpinfo清楚地顯示哪一個是真正使用的)

    2.1。並用xdebug.remote_enable = 1和xdebug.remote_autostart = 1進行配置。我的工作示例:

    [XDebug] 
    zend_extension = "c:\wamp64\bin\php\php7.1.9\ext\php_xdebug-2.6.0beta1-7.1-vc14-x86_64.dll"  
    xdebug.stopOnEntry = true 
    xdebug.profiler_enable = off 
    xdebug.profiler_enable_trigger = Off 
    xdebug.profiler_output_name = cachegrind.out.%t.%p 
    xdebug.profiler_output_dir ="c:/wamp64/tmp" 
    xdebug.show_local_vars=0 
    ;xdebug.profiler_output_name = "cachegrind.out.%t-%s" 
    xdebug.remote_enable = 1 
    xdebug.remote_autostart = 1 
    xdebug.remote_handler = "dbgp" 
    xdebug.remote_host = "127.0.0.1" 
    xdebug.remote_log = "C:\wamp64\tmp\xdebug.txt" 
    xdebug.remote_port = 9000 
    xdebug.trace_output_dir = "C:\wamp64\tmp" 
    xdebug.remote_cookie_expire_time = 36000 
    
  • 重新啓動Apache2 Web服務器。

  • 另外:

    出於某種原因,我第一次來到了XDebug的NetBeans工作進行測試,然後才我發現在手動選項xdebug.remote_autostart = 1,使得它在VS代碼工作也。

    如果您不確定XDebug的安裝情況,請檢查phpinfo頁面是否帶有Xdebug字樣,並檢查logs/apache_errors.log中是否有「加載php_xdebug失敗」(不正確的DDL下載)。然後檢查任何其他IDE。

    好的問候!