Per Søderlind

I code for fun

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)

Previous

Relocating my WordPress plugins to GitHub

Next

WordPress Debug Bar, List Script & Style Dependencies

3 Comments

  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.

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

  3. PerS

    I switch to the xdebug client (remove xdebug from ST using package remove before you install xdebug client). It works like a charm

Leave a Reply

Powered by WordPress & Theme by Anders Norén