步骤1:查看PHP版本
通过phpinfo()查看版本 通过红色标记处,确定xdebug的版本
步骤2:下载debug文件
步骤3:vscode安装php debug 插件
打开vscode,安装PHP_Debug插件
步骤4:配置php.ini
打开php.ini,在文档尾部写入以下配置,Xdebug 3与之前2的配置参数不一样,请留意。
此处为xdebug3
[Xdebug]
zend_extension=php_xdebug-3.0.4-7.3-vc15-nts-x86_64.dll;
xdebug.mode=trace;
xdebug.start_with_request=yes;
xdebug.mode=debug;
xdebug.remote_handler = "dbgp";
xdebug.client_port = "9003"; 端口号,与vscode配置保持一致
xdebug.client_host = "127.0.0.1"; 远程调试的ip地址,即你自己的本机ip
此处为xdebug2
[XDebug]
zend_extension=php_xdebug.dll
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9003
步骤5:配置vscode
在程序目录下打开vscode,选择 运行和调试,点击 创建 launch.json文件,如果安装有多个环境,会提示,选择 php即可。
选择后会出现默认配置项
步骤6:运行测试
点击 运行和调试 点击 开始调试 打上断点 效果如图
完成。