Search code examples
phpvisual-studio-codexamppxdebugvscode-debugger

PHP Debug with Xdebug not stopping on breakpoints (XAMPP)


First, I'm very new to PHP. I'm trying to use the PHP Debug extension in VS Code with PHP Version 8.0.2 and Xdebug Version 3.0.2.

I've switched the Apache ports to 9000/90001. Everything seems to work correctly in the browser when I navigate to localhost:9000/test.php. However, when I try to debug in VS Code, the breakpoints are never triggered.

My PHP.ini Xdebug section:

[XDebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-3.0.2-8.0-vs16-x86_64.dll"
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9000
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.idekey = VSCODE
xdebug.remote_host=127.0.0.1
xdebug.default_enable=1

xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
xdebug.remote_handler = "dbgp"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.trace_output_dir = "c:\xampp\tmp"
xdebug.remote_cookie_expire_time = 36000

My 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": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "",
            "cwd": "",
            "port": 9000
        },
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        }
    ]
}

Any help here would be greatly appreciated!


Solution

  • Your configuration contains mixed statements from different XDebug versions (v2.x and v3), while your XDebug extension looks to be v3. Please take a look at the following guide to understand which configuration should belongs to v3:

    https://xdebug.org/docs/upgrade_guide

    I have succeeded with this config using v3:

    xdebug.mode = debug
    xdebug.start_with_request = yes
    xdebug.client_host=192.168.1.3
    xdebug.client_port=9000
    xdebug.log=/tmp/xdebug.log