vscode调试php8.0

按照网上的操作,基本上无解。发现php8.0中自带的xdebug版本为3.0.调试无法进入断点,很可能跟这个配置有关系。xedubg更新了一些新的配置名称。

xdebug.remote_enable这些配置项的值在xdebug3.0中会变成(renamed in version 3)

相同的配置把php换成 7.3 就可以跳入断点。

刚才进入worldpress后台,竟然提示我使用的php7.3是过时的版本。php发展的这么快了吗?

总结:不要尝试使用xdebug3.0调试php8.0程序,网上能搜到的方案都解决不了问题。目前是一个大坑。把你的php降级到7.3以下。7.4没有测试,不发表结论。

1、settings.json:

 “php.validate.executablePath”: “D:\\phpstudy_pro\\Extensions\\php\\php7.3.4nts\\php.exe”,

2、launch.json:

{

    // 使用 IntelliSense 了解相关属性。

    // 悬停以查看现有属性的描述。

    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387

    “version”: “0.2.0”,

    “configurations”: [

      {

        “name”: “Listen for XDebug”,

        “type”: “php”,

        “request”: “launch”,

        “port”: 9001

      },

      {

        “name”: “Launch currently open script”,

        “type”: “php”,

        “request”: “launch”,

        “program”: “${file}”,

        “cwd”: “${fileDirname}”,

        “port”: 9001

      }

    ]

  }

3、php.ini

[XDebug]
zend_extension=”D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext\php_xdebug.dll”
xdebug.auto_trace=1
xdebug.collect_params=1
xdebug.collect_return=1
xdebug.profiler_output_dir=”D:\xdebug”
xdebug.trace_output_dir=”D:\xdebug”
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “127.0.0.1”

设置端口号,默认是9000,此处因为本地环境端口冲突故设置为9001(在vscode配置中需要用到)

xdebug.remote_port = 9001