Skip to content

Commit 36ebbad

Browse files
committed
vscod调试php配置
1 parent 23ae923 commit 36ebbad

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

src/develop/php/README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# PHP
2+
3+
## phpstudy + VSCode 环境配置
4+
5+
* 用phpstudy安装php、apache/nginx,还可能用到mysql
6+
7+
* phpstudy -- 软件管理 -- 选择安装的PHP设置 -- 打开调试组件
8+
9+
(记住这里的端口9000,也可以修改)
10+
11+
![image-20241219222839125](./img/README/image-20241219222839125.png)
12+
13+
* 在php.ini中添加配置
14+
15+
```apl
16+
[Xdebug]
17+
zend_extension=D:/phpstudy_pro/Extensions/php/php7.3.4nts/ext/php_xdebug.dll
18+
xdebug.collect_params=1
19+
xdebug.collect_return=1
20+
xdebug.auto_trace=On
21+
xdebug.trace_output_dir=D:/phpstudy_pro/Extensions/php_log/php7.3.4nts.xdebug.trace
22+
xdebug.profiler_enable=On
23+
xdebug.profiler_output_dir=D:/phpstudy_pro/Extensions/php_log/php7.3.4nts.xdebug.profiler
24+
xdebug.remote_enable=On #修改为On
25+
xdebug.remote_autostart = On #添加
26+
xdebug.remote_host=localhost
27+
xdebug.remote_port=9000 #修改成对应端口
28+
xdebug.remote_handler=dbgp
29+
```
30+
31+
* vscode安装``PHP Extension Pack`插件,里面包括`PHP Debug``PHP IntelliSense`
32+
33+
![image-20241219222625307](./img/README/image-20241219222625307.png)
34+
35+
* 修改vscode设置,填写php和xdebug的地址
36+
37+
```json
38+
"php.executablePath": "D:/install/phpstudy_pro/Extensions/php/php7.4.3nts/php.exe",
39+
"php.debug.executablePath": "D:/install/phpstudy_pro/Extensions/php/php7.3.4nts/ext/php_xdebug.dll",
40+
```
41+
42+
* 对vscode的调试页面进行配置
43+
44+
![image-20241219223114831](./img/README/image-20241219223114831.png)
45+
46+
```json
47+
{
48+
"version": "0.2.0",
49+
"configurations": [
50+
{
51+
"name": "Listen for Xdebug",
52+
"type": "php",
53+
"request": "launch",
54+
"port": 9000
55+
},
56+
{
57+
"name": "Launch currently open script",
58+
"type": "php",
59+
"request": "launch",
60+
"program": "${file}",
61+
"cwd": "${fileDirname}",
62+
"port": 9000,
63+
"runtimeArgs": [
64+
"-dxdebug.start_with_request=yes"
65+
],
66+
"env": {
67+
"XDEBUG_MODE": "debug,develop",
68+
"XDEBUG_CONFIG": "client_port=${port}"
69+
}
70+
}
71+
]
72+
}
73+
```
74+
75+
* 打断点开始调试
128 KB
Loading
57.7 KB
Loading
131 KB
Loading

0 commit comments

Comments
 (0)