【PHP】使用VSCode调试 | XDebug

使用的phpstudy,自己配置也是一样的

开启xdebug拓展

【PHP】使用VSCode调试 | XDebug

如果是手动安装,需要去官网下载xdebug.dll,并放在ext文件夹里

修改PHP配置文件

【PHP】使用VSCode调试 | XDebug

手动党就找到 php安装目录/php.ini

直接拉到文件最后,或者搜索[Xdebug] ,修改这2个,有就改,没有就加

xdebug.remote_autostart=1
xdebug.remote_enable=1

完整演示

端口号是9000,你可以自己改,记一下,后面要用

[Xdebug]
zend_extension=D:/php/phpstudy/Extensions/php/php7.4.3nts/ext/php_xdebug.dll
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.auto_trace=Off
xdebug.trace_output_dir=D:/php/phpstudy/Extensions/php_log/php7.4.3nts.xdebug.trace
xdebug.profiler_enable=Off
xdebug.profiler_output_dir=D:/php/phpstudy/Extensions/php_log/php7.4.3nts.xdebug.profiler
xdebug.remote_autostart=1
xdebug.remote_enable=1
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_handler=dbgp

VScode 插件配置

安装这俩PHP Debug和PHP Intelephense

然后点击Debug的小齿轮 – 选择扩展设置

【PHP】使用VSCode调试 | XDebug

选择在setting.json中编辑

【PHP】使用VSCode调试 | XDebug

修改配置,后面改成你的php安装路径(有就改,没有就加)

"php.validate.executablePath":"D:\\php\\phpstudy\\Extensions\\php\\php7.4.3nts\\php.exe",  // 验证
"php.executablePath":"D:\\php\\phpstudy\\Extensions\\php\\php7.4.3nts\\php.exe",   // 运行时解释器指向
"php.debug.executablePath": "D:\\php\\phpstudy\\Extensions\\php\\php7.4.3nts\\php.exe",  // 调试

【PHP】使用VSCode调试 | XDebug

调试设置

单击调试文件配置launch.json,会自动创建一个文件,并且一堆话

【PHP】使用VSCode调试 | XDebug

修改端口号即可,就是php.ini里x-debug设置里的端口号

【PHP】使用VSCode调试 | XDebug

重启apache

字面意思

测试文件

完成!

【PHP】使用VSCode调试 | XDebug

给TA充电
共{{data.count}}人
人已充电
vscode编程

【VSCode】无法将xx项识别为 cmdlet、函数、脚本文件或可运行程序的名称。

2022-5-12 17:23:40

vscode编程

【Go】安装与配置 VScode

2022-5-14 8:10:57

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
今日签到
搜索