Remote Debugging PHP in Visual Studio Code with XDebug

Remote Debugging PHP in Visual Studio Code with XDebug prereqs:
1) This post assumes you already have a working xdebug install
2) vscode

How to get Xdebug working with Visual Studio Code?

  • Open vscode
  • Goto the extensions tab (the last icon on the left pane)
  • Search for ‘PHP Debug’
  • Click install
  • Click restart
  • Click the debug tab (looks like a bug with a line through, usuallyits the icon above the extensions tab in the left pane)
  • Make sure that “listen to xdebug” is selected
  • Click the ‘play’ icon (or press F5) to start the debugging session

Setting Up Remote Debugging Paths

  • Click the gear-icon
  • Add the following to the “Listen for XDebug” section

"stopOnEntry": true,
"pathMappings": {
    "/var/www/vhosts/": "${workspaceRoot}/",
}

The exact path mappings will depend on your project
Click the ‘play’ icon (or press F5) to start the debugging session

PHP Step Debugging

To set a breakpoint, click on the gutter to the left of the line number

Remote Debugging PHP in Visual Studio Code with XDebug

Remote PHP Debugging Using Eclipse: Initiating a debug session:

Install the easy-xdebug instension in your browser:

Firefox
Xdebug Helper is the best solution I have found for firefox – simply install the extension from here

Using Firefox

Xdebug Helper is the best solution I have found for firefox – simply install the extension from here, navigate to the site you want to debug, and click the little green bug, select debug and reload your page to open in your editors debugger.

Using Chrome

Xdebug Helper is the best solution I have found for chrome – simply install the extension from here, navigate to the site you want to debug, and click the little green bug, select debug and reload your page to open in your editors debugger.

lastly, navigate to the site you want to debug, and click the little green bug, select debug and reload your page to open in your editors debugger. You are now Remote Debugging PHP in Visual Studio Code with XDebug!

refs:
https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
https://scotch.io/@chenster/debugging-php-in-visual-studio-code205

Tags for Remote Debugging PHP in Visual Studio Code with XDebug

Chrome Eclipse Firefox Icon Install Open Php Play Remote Search Session Sure Xdebug