vscode PHP 斷點調試
發表時(shí)間:2022-4-10
發布人(rén):融晨科技
浏覽次數:115
這(zhè)兩天修改一個(gè)PHP程序,用VScode ,我對PHP不(bù)熟的(de),以(yǐ)前也(yě)沒研究過調試的(de)相關知識,向來(lái)都是(shì)直接幹,或者直接echo,但echo始終有點不(bù)方便,查找了(le/liǎo)相關的(de)資料,總結了(le/liǎo)vscode 調試的(de)php 的(de)過程,胡亂看看吧~~
1.phpinfo打印出(chū)PHP信息,複制信息到(dào)xdebug
xdebug點擊進入
2.提交以(yǐ)後系統會自動偵測PHP版本信息并給出(chū)下載鏈接
3.下載以(yǐ)後放到(dào)php對應版本的(de)ext 目錄,然後根據提示修改php.ini配置文件
zend_extension = xdebug
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.romote_host=localhost
xdebug.remote_port=9003
下邊的(de)配置vscode 會用的(de)到(dào),記住端口号,打開phpinfo查看是(shì)否成功
有xdebug信息就(jiù)是(shì)說(shuō)明可以(yǐ)了(le/liǎo)。下邊轉vscode
4.安裝phpdebug插件
5.php debug配置
{
"workbench.colorTheme": "Default Dark+",
"editor.quickSuggestions": {
"strings": true
},
"php.validate.executablePath": "D:/BtSoft/php/72/php.exe",
"php.debug.executablePath": "D:/BtSoft/php/72/php.exe"
}
主要(yào / yāo)是(shì)倒數第二個(gè)配置,對應php執行文件
6.vscode 運行,配置
{
// 使用 IntelliSense 了(le/liǎo)解相關屬性。
// 懸停以(yǐ)查看現有屬性的(de)描述。
// 欲了(le/liǎo)解更多信息,請訪問: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://127.0.0.1:%s",
"action": "openExternally"
}
}
]
}
修改端口号爲(wéi / wèi)剛才php.info的(de)端口号。
7.F5~~~~
————————————————
版權聲明:本文爲(wéi / wèi)CSDN博主「融晨科技」的(de)原創文章,遵循CC 4.0 BY-SA版權協議,轉載請附上(shàng)原文出(chū)處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/ynkui/article/details/124087784