How to get Xdebug working with Visual Studio Code?

It’s working fine for me. My launch.json file is below.

BTW, I also made some changes to the php.ini file so that I would not need the browser helper thing. I’ve included the appropriate xdebug section below as well.

I hope some of that is useful to you.

Regards,
Ben

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": 9000,
            "pathMappings": {
                "/app/public": "${workspaceFolder}",
            },
            "xdebugSettings": {
                "max_children": 256
            },
            "log": false,
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

php.ini

    [Xdebug]
zend_extension = /opt/php/7.1.4/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=On
xdebug.remote_port="9000"
xdebug.profiler_enable=0
;
; Added by Ben Riga Feb 24, 2018
xdebug.remote_autostart = 1
xdebug.var_display_max_depth = 5
xdebug.var_display_max_children = 256
xdebug.var_display_max_data = 1024 
;
;
4 Likes