Debug WordPress with Sublime Text 2 and XDebug

sublime-text-plugin-debug

XDebug installation

  1. Run the Xdebug wizard and follow the instructions.I develop on Mac OS X Mountain Lion, and phpize complained that autoconf is missing.

    Luckily Sebastien has the recipe on how to add autoconf to Mountain Lion
  2. When you’re editing php.ini, add the following to the [xdebug] section
  3. Save php.ini and restart your webserver. I do sudo apachectl restart

Debug your WordPress plugin in Sublime Text 2

  1. If you haven’t allready, add the SublimeXdebug package using Sublime Package Control
    • Shift-Cmd P and select Package Install
    • Find Xdebug and install it
  2. Open the folder with the plugin you want to debug in Sublime Text and save as project (Project -> Save Project As…)
  3. Edit project properties (Project->Edit Project) and add the “settings”: {“xdebug” : url-to-your-test-site}. Mine is:
  4. Now you’re ready to debug:
    • Select the line where you want a breakpoint. Shift + F8 opens the debug menu. Select Add Breakpoint
    • Shift + F8, and choose Start debugging. Your default broweser will open with the url you set in project properties. Browse to the page where you know the plugin will be triggered, and go back to Sublime Text.
    • Use the following shortcut keys to step through the code:
      • Ctrl+Shift+F6 – Step over
      • Ctrl+Shift+F7 – Step into
      • Ctrl+Shift+F8 – Step out from
      • Ctrl+Shift+F5 – Continue (until next breakpoint)

3 thoughts on “Debug WordPress with Sublime Text 2 and XDebug

  1. Ivan Zhang

    i follow all the steps above, and when i hit Shit + F8, nothing happens…

    any thing wrong? i used to make xdebug work on my mac book air with phpstorm.

    Reply
  2. maik

    same problem here…
    on pressing fn+f8 (not shift+f8) sublime displays a message on the bottom: “Xedbug: Not running”
    please help

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">