PHP配置xdebug的方法
一、查看PHP對應的xdebug版本并下載
1、創建一個php檔案,檔案內容如下圖,將這個檔案放到Apache服務器訪問根目錄下

2、重瀏覽器輸入本地地址訪問Apache服務器,查看相應的PHP版本

3、將這個頁面顯示所有資訊復制,訪問網址https://xdebug.org/wizard.php,并將復制的資訊粘貼到文本框里,點擊下方的Analyse my phpinfo() output按鈕


4、下載其建議的dll檔案

5、將下載的檔案放到PHP的安裝目錄下的ext檔案夾下,我這里用的是xampp集成軟體

6、找到PHP目錄下的php.ini檔案并打開,在檔案內容最后一行下面輸入
[xdebug]
zend_extension = D:\xampp\php\ext\php_xdebug-2.9.6-7.3-vc15.dll //這個路徑是剛才下載的那個dll檔案存放的路徑
xdebug.remote_enable=on
xdebug.remote_autostart=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.romote_host=localhost
xdebug.remote_port=9000

7、在vscode上搜索phpdebug插件并安裝

8、打開launch.json檔案并配置引數
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: 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
}
]
}

9、打開VScode的設定"php.validate.executablePath": "D:\\xampp\\php\\php.exe",//這里是你php安裝目錄下的檔案,如果沒有內容就添加進去,如果有就修改


10、啟動xdebug,從瀏覽器訪問你的專案,會跳轉到你的代碼,說明就成功了,你就可以利用php的除錯查找你的代碼的錯誤
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/20931.html
標籤:PHP
上一篇:java web 查詢檔案報錯 Failed to parse multipart servlet
下一篇:后臺實作頁面可配置
