xDebug + VSCode - breakpoints not hit when debugging

Hi,

I have installed Local and can get my wordpress site to work, but cannot get the breakpoints to hit when debugging in VSCode.

I followed the steps to setup debugging:
https://localwp.com/community/t/localbyflywheel-xdebug-vscode/11950/9

SETUP

  1. Install the add-on
  2. Enable the add-on & Relaunch Local
  3. Go to the site you want to debug in Local
  4. Start the site
  5. Click on the Utilities tab
  6. Click the “Add Run Configuration to VS Code” link - this will create an xdebug/vscode configuration file inside the app/public folder

Debugging

  1. Open the app/public folder in vscode
  2. Start debugging (command/control + shift + p and then type “debug” then click “Debug: Start Debugging”
  3. Load the site in your browser

I then open my index.php file in VSCode and set several breakpoints. I refresh the site in the browser, but my breakpoints are not hit.

Here is my launch.json
{

"version": "0.2.0",

"configurations": [

    {

        "name": "Listen for Xdebug (Local)",

        "type": "php",

        "request": "launch",

        "port": 9000,

        "xdebugSettings": {

            "max_children": 128,

            "max_data": 1024,

            "max_depth": 3,

            "show_hidden": 1

        }

    },

    {

        "name": "Launch currently open script",

        "type": "php",

        "request": "launch",

        "program": "${file}",

        "cwd": "${fileDirname}",

        "port": 9000,

        "xdebugSettings": {

            "max_children": 128,

            "max_data": 1024,

            "max_depth": 3,

            "show_hidden": 1

        }

    }

]

}

When I start my website in Local, the url that appears in my browser is:
http://localhost:10005

I have tried altering the port in my launch.json to 10005, but it has no affect.

Any help would be much appreciated.

Which index.php file are you accessing? You might try setting a breakpoint within the wp-config.php file since sometimes the index.php file of a WP project isn’t run.

Hi Ben,

Thanks for the help. I had added this line to my index.php

echo ‘this shows we have made it here’;

and put the breakpoint on that line. I can see the text is output on my site, so I know the line is being executed. Unfortunately, the breakpoint was not hit.

Also also tried your suggestion & put the breakpoint at wp-config.php but it was not hit there either.

Out of curiosity what version of PHP are you using on the site in question?

I actually got this working. I am not sure what version of XDebug is shipped with Local, so I added these lines to my php.ini.hbs

xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9003

I then changed the port in my launch.json from 9000 to 9003

1 Like

PHP 8 includes xDebug 3.0 which requires the port change to 9003

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.