vscode+phpstudy+xdebug无法断点(踩坑记)
一、软件下载
安装vscode、下载phpstudy最新版这2步都不说了,网上大把教程。本文主要把phpstudy的一个坑点记录一下
vscode下载地址:
https://code.visualstudio.com/
phpstudypro下载地址:
通过百度网盘分享的文件:phpstudypro_x64_8.1.1.3.zip
链接:https://pan.baidu.com/s/1wzm0sqZCQS4NxvIf1jSrtw?pwd=6c6j
提取码:6c6j
二、phpstudy配置
配置网站
配置伪静态
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
try_files $uri $uri/ =404;
}
开启phpxdebug
开启后,查看 xdebug 信息 phpinfo.php
配置php设置xdebug
三、vscode安装插件
vscode 配置 launch.json
{
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"stopOnEntry": true,
"port": 9002
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 9002,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
}
]
}
装完插件,然后配置插件:File--Preferences--Settings--Extensions--PHP:
写入你要用的php版本所在位置:
"php.validate.executablePath": "D:\\phpstudypro\\Extensions\\php\\php7.1.9nts\\php.exe"
四、配置php.init
[Xdebug]
zend_extension="D:\phpstudypro\Extensions\php\php7.1.9nts\ext\php_xdebug.dll"
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=On
xdebug.trace_output_dir="D:\phpstudypro\Extensions\php_log\php7.1.9nts.xdebug.trace"
xdebug.profiler_enable=On
xdebug.profiler_output_dir="D:\phpstudypro\Extensions\tmp\xdebug"
xdebug.remote_enable=On
xdebug.remote_autostart = On
xdebug.remote_host=localhost
xdebug.remote_port=9002
xdebug.remote_handler=dbgp
xdebug.remote_autostart = 1
xdebug.remote_log = D:/phpstudypro/Extensions/tmp/xdebug/log/php/xdebug2.log
重启WNMP
重启网站
五、测试断点
打断点
启动监听debug程序
按F5 或者 点启动按钮
http请求接口
进入断点
[Haima的博客]
http://www.cnblogs.com/haima/