VS Code Debugger - Felix Becker - Debugger doesn't hit anything

自古美人都是妖i 提交于 2021-01-20 09:08:39

问题


I have recently installed php debugger by Felix Becker. No matter whatever config settings I do, my debugger is not hitting anything. Following are my conf files.

xdebug.ini

[xdebug]
; debug
xdebug.default_enable = $value
xdebug.remote_autostart = $value
xdebug.remote_connect_back = 0
xdebug.remote_host = $value
xdebug.remote_port = $value
xdebug.remote_enable = 1
xdebug.idekey = $value

; profiling
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = /tmp

zend_extension=xdebug.so

Launch.json

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9009,
            "pathMappings": {
                "path/path": "$value"
            }
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
  
            "port": 9009,
            "pathMappings": {
                "path/path": "$value"
            }
        }
    ]
  }

Am I missing anything here ?


回答1:


Xdebug v3.0.1, by Derick Rethans

You are using Xdebug v3 but keep using Xdebug v2 config parameters. You need to go through Upgrading from Xdebug 2 to 3 Guide and adjust your settings (mostly just change the parameter name).

Xdebug v3 uses different config params than Xdebug v2. From what I see 8 out of 9 "xdebug." params from your current php.ini do nothing in Xdebug v3.

For Xdebug 3 it should be something like this (based on your original config):

zend_extension=xdebug.so

[xdebug]
xdebug.mode = debug
; for profiling switch to below:
;xdebug.mode = profile

xdebug.client_host = ${PHP_XDEBUG_REMOTE_HOST}
xdebug.client_port = ${PHP_XDEBUG_REMOTE_PORT}
xdebug.discover_client_host = false
xdebug.start_with_request = ${PHP_XDEBUG_REMOTE_AUTOSTART}
xdebug.idekey = ${PHP_XDEBUG_IDE_KEY}
xdebug.output_dir = /tmp

P.S. xdebug.discover_client_host will now fallback to xdebug.client_host on failure (unlike v2 that would try autodetected host only).

P.P.S. xdebug.default_enable = 1 is replaced by xdebug.mode = develop. If you need that then you can list multiple values via comma, e.g. xdebug.mode = develop,debug




回答2:


A fix for Becker extension was pushed in v1.52.1, see https://github.com/microsoft/vscode/issues?q=is:issue+milestone:%22November+2020+Recovery%22+is:closed


The php debugger extension by Felix Becker is using previously-deprecated api and so the last vscode version 1.52 means it won't hit breakpoints. There are many issues on vscode's github on this. A vscode team member suggests enabling this setting to fix:

Debug: Allow Breakpoints Everywhere

see https://github.com/microsoft/vscode/issues/112288#issuecomment-743456329

The other option is to use a different extension which has updated its code to accommodate the deprecations. For examples, see https://github.com/felixfbecker/vscode-php-debug/issues/424#issuecomment-727932756



来源:https://stackoverflow.com/questions/65316966/vs-code-debugger-felix-becker-debugger-doesnt-hit-anything

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!