vscode配置PHP Debug


1、先在vscode中安裝PHP Debug,在設置添加“php.validate.executablePath”項,選中對應版本的php.exe。

 

"php.validate.executablePath": "d:\\wamp\\bin\\php\\php7.2.14\\php.exe",

 

2、按F5調試,選擇PHP,就可以了,可能會配置失敗。

3、按 Ctrl+Shift+D 打開調試面板,點擊上面的小齒輪打開launch.json,如果出現“Listen for XDebug”和“Launch currently open script”,就證明成功了,

可以調試了。

4、如果發現沒有,就需要手動添加了:

{
  // 使用 IntelliSense 了解相關屬性。 
  // 懸停以查看現有屬性的描述。
  // 欲了解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
  "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
    }
  ]
}

5、然后在隨便一個頁面輸出一下phpinfo(); Ctrl+A 復制頁面的內容到 https://xdebug.org/wizard.php 的文本框內,點擊下面的 Analyse my phpinfo() output 按鈕獲取對應的xdebug.dll文件,下載下來放到當前版本php目錄下的zend_ext文件夾內。

6、配置apache下的php.ini文件

D:\wamp\bin\apache\apache2.4.37\bin\php.ini

[XDebug]
zend_extension = "D:/wamp/bin/php/php7.2.14/zend_ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll" :對應下載的xdebug的目錄
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.romote_host=localhost
xdebug.remote_port=9000 //關鍵在於這個端口號要和launch.json配置的端口號對應起來。

 

然后重啟服務器就ok啦。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM