Xdebug in sublime text

Remote Debugging PHP in SublimeText with XDebug prereqs: This post assumes you already have

  1. a working xdebug install
  2. SublimeText

How to get Xdebug working with Sublime Text?

  • Open SublimeText
  • Open the package install dialog (cmd+shift+p then type “pack inst”)
  • Search for ‘xdebug’
  • Select Xdebug Client and Press enter
  • install xdebug extension.png

Setting Up Remote Debugging Paths

  • Open the xdebug user preferences
  • (cmd+shift+p then type “xdebug” then select “Preferences: Xdebug User”)
  • Add the following to the user prefs file:
{
    path_mapping": {
        "/var/www/vhosts/": "/Users/myuser/git/projectname",
    }
}

The exact path mappings will depend on your project

path_mapping.png

PHP Step Debugging

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

breakpoint.png

Remote PHP Debugging Using Eclipse: Initiating a debug session:

Install the easy-xdebug instension in your browser:

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.

Start Debugging

cmd+shift+p then xdebug: start debugging (or cmd+shift+F9)

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.

xdebug menu.png

You are now Remote Debugging PHP in Sublime Text with XDebug!