在按照Jerry的公眾號文章 什么?在SAP中國研究院里還需要會PHP開發? 進行XDebug在本地的配置之后,如果想使用Visual Studio Code而不是Eclipse來調試PHP應用,步驟也比較簡單。
啟動WAMP服務器,確保xdebug.remote_autostart, xdebug.remote_enable都為on:
然后安裝Visual Studio Code的擴展:PHP Debug
安裝完畢后,File->Preferences->Settings:
添加一條entry:php.validate.executablePath, 指向你本地的php.exe
在這里小編建了一個前端學習交流扣扣群:132667127,我自己整理的最新的前端資料和高級開發教程,如果有想需要的,可以加群一起學習交流
創建一個PHP debug configuration,有兩種方式選擇:
Launch current open script和Listen for Xdebug:
{
// 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,
"runtimeExecutable":"C:\\MyApp\\wamp20190709\\bin\\php\\php7.0.10\\php.exe"
}
]
}
前者調試PHP CLI應用比較方便,打開一個php文件,直接F5,斷點即觸發。
如果選擇成Listen for XDebug,同樣先F5啟動調試進程,
然后瀏覽器里訪問待調試的PHP文件,Visual Studio Code的斷點即觸發,可以單步調試了:
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。