我这边是可以调试的,但别人无法复现成功我的操作。
相关网站:Xdebug: Support — Tailored Installation Instructions
版本如下:
phpstudy_pro 8.1.1.3
php7.3.4 (已配置环境变量)
vscode 1.89.0
phpstudy_pro wnmp服务如下
nginx1.15.11
mysql5.7.26
vscode关键插件
IntelliPHP - AI Autocomplete for PHPv0.12.15062
预览版
PHPv1.46.15395
PHP Debugv1.34.0
PHP Intelephensev1.10.4
PHP Profilerv1.46.15395
PHP Xdebugv0.0.7
我以管理员身份开启vscode与phpstudy,先写了个index.php,可以在127.0.0.1:80/index.php访问。
phpstudy_pro开启xdebug
WWW/.vscode/launch.json里面
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: 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,
"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://localhost:%s",
"action": "openExternally"
}
}
]
}
文件->首选项->设置,搜索php,点击蓝色部分。
settings.json
{
"python.linting.flake8Enabled": true,
"python.formatting.provider": "yapf",
"python.linting.flake8Args": ["--max-line-length=248"],
"python.linting.pylintEnabled": false,
"explorer.confirmDelete": false,
"json.schemaDownload.enable": false,
"php.validate.executablePath": "C:/phpstudypro/Extensions/php/php7.3.4nts/php.exe",
"php.debug.executablePath":"C:/phpstudypro/Extensions/php/php7.3.4nts/php.exe"
}
C:\phpstudypro\Extensions\php\php7.3.4nts\php.ini修改对应部分
[Xdebug]
zend_extension=C:/phpstudypro/Extensions/php/php7.3.4nts/ext/php_xdebug.dll
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=On
xdebug.trace_output_dir=C:/phpstudypro/Extensions/php_log/php7.3.4nts.xdebug.trace
xdebug.profiler_enable=On
xdebug.profiler_output_dir=C:/phpstudypro/Extensions/php_log/php7.3.4nts.xdebug.profiler
xdebug.remote_enable=On
xdebug.remote_autostart=On
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.mode=debug
xdebug.start_with_request=yes
phpstudy_pro开启wnmp服务,vscode里打断点,F5开启调试
刷新页面
可以看到我左边变量栏是有东西的,但其他人做到这一步左边是没有东西的,原因未知。
大家可以继续研究一下,成功了麻烦在评论区留下言,到时候我更新一下。