您當前位置>首頁 » 新聞資訊 » 技(jì)術(shù)分(fēn)享 >
vscode PHP 斷點調試
發表時(shí)間(jiān):2022-4-10
發布人(rén):葵宇科(kē)技(jì)
浏覽次數(shù):115
這(zhè)兩天修改一(yī)個(gè)PHP程序,™¶用(yòng)VScode ,我對(duì)PHP不(bù)熟的(de),以前↓∞♥也(yě)沒研究過調試的(de)相(xiàng)關知(zhī)識,向來(lái)都(dō♦ε"u)是(shì)直接幹,或者直接echo,但(dàn)echo始€₹終有(yǒu)點不(bù)方便,查找了(le)相(xiàng)關的(de)資料,總結了(le)♠∞→★vscode 調試的(de)php 的(de)過程,胡亂看(kàn)看(kàn)吧(b↓→a)~~
1.phpinfo打印出PHP信息,複制(zhì)信息到(♥εdào)xdebug
xdebug點擊進入
2.提交以後系統會(huì)自(zì)動偵測PHP版本信息并給出下(xià)載鏈接
3.下(xià)載以後放(fàng)到(dào)php對(duì)應∑✘♦版本的(de)ext 目錄,然後根據提示修改php.ini配置★σ∑文(wén)件(jiàn)
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
下(xià)邊的(de)配置vscode 會(huì)用(yòng)的(de)到<♦★(dào),記住端口号,打開(kāi)phpinfo查看(kàn)是(shì)否成功
有(yǒu)xdebug信息就(jiù)是(shì)說(shuō)明(míng)>§ ≥可(kě)以了(le)。下(xià)邊轉vscode
4.安裝phpdebug插件(jiàn)
5.php debug配置
{
"workbenc✔♣•↓h.colorTheme": "Defaul→εε&t Dark+",
"editor.quickSuggest♦ ↑≥ions": {
"strings&¥•↕quot;: true
},
"php.vaα₹lidate.executablePath"★ ®: "D:/BtSoft/php/72/phβ←♣p.exe",
"php.debug.exec≥★©utablePath": "D:/BtSoft/php/72/phpε$α.exe"
}
主要(yào)是(shì)倒數(shù)第二個(gè)配置,對(duì)α應php執行(xíng)文(wén)件(jiàn)
6.vscode 運行(xíng),配置
{
// 使用(yòng) IntelliSense 了(le)解相(x↔δ✔ iàng)關屬性。
// 懸停以查看(kàn)現(xiàn)有(yǒu)屬性的(dγ ♥e)描述。
// 欲了(le)解更多(du← ō)信息,請(qǐng)訪問(wèn): https://go.microsoft.co₩↕βm/fwlink/?linkid=830387
"version": &q₽ε÷δuot;0.2.0",
"configurations&q©uot;: [
{
 ∏ ✘♥; "name": "Listen fo£♦r Xdebug",
">βφ;type": "php",
σ "request": "launch",
&↑">nbsp; "port": 9003
→∑> },
 •πγ♥; {
&nb↑∏₩sp; "name": "Laun →₩¥ch currently open script",
&nb$•sp; "type": "php&♠↔®↕quot;,
&nbs•φα♠p; "request": "launch&q≈Ω♣$uot;,
&q↔δuot;program": "${file}"," γ
"cβγwd": "${fileDirname}",
"p$§Ω"ort": 0,
&q×<uot;runtimeArgs": [
φ÷ "-dxdebug.sta₩≥rt_with_request=yes"
&n →bsp; ],
λ "env": {
&n✘α≥πbsp; "XDEBUα×$G_MODE": "debug,develop"♠↕₹;,
±€ "XDEBUG_→ ★ CONFIG": "client_port=${port}"
}<↓"
→§},
{
α↕ "name": "Launch Built-in↕↔÷ web server",
&quo∏∞✔t;type": "php",
¥★ "request&qu♣↑ot;: "launch",
×γ""runtimeArgs": [
 φ©; "-dxdebug.mod¶δ→ e=debug",
&π≈"≈nbsp; "-dxde∑"∏bug.start_with_request=yes",
&γ→nbsp; &quo® t;-S",
≤δ× "loca✘€lhost:0"
→¶σ],
  £≠ ; "program": "",
π★•★"cwd": "${workspaceRoot}♦↑<",
 $"; "port":↕β 9003,
&quo↔∑πt;serverReadyAction": {
 &∑; "pattern": "Develε∏'opment Server \\(http://localhost:([0-9]+✔♥)\\) started",
&nb&←©≤sp; "uriFormat&q★ uot;: "http://127.0.0≠✘σ§.1:%s",
 ∏♣£; "action": "®∑openExternally"
₽↕ }
}
]
}
修改端口号為(wèi)剛才php.info的(d'≠e)端口号。
7.F5~~~~
——————&md®>✔ash;—————&mdas≈&≈₹h;———
版權聲明(míng):本文(wén)為(wèi)CSDN博主「葵宇科(kē)技(jì)」的(♠≈≤♥de)原創文(wén)章(zhāng),遵循CC 4≈≥.0 BY-SA版權協議(yì),轉載請(qǐng)附上(shàng)原文(w∞én)出處鏈接及本聲明(míng)。
原文(wén)鏈接:https://blog.csdn.net/ynkui/artφ'icle/details/124087784