Xdebug Toggler for Safari

I’ve been developing on a mac since I was at university in 2002 but this was mainly for personal projects as I used Windows/Ubuntu at work. Recently I’ve managed to convert my work machine into a macbook pro, so I wanted to start using Safari as the browser of choice. The development tools available are fantastic, and they are built right into the browser.

One of the main tools I use on a daily basis is Eclipse PDT which integrates into Xdebug out of the box, however sometimes you simply don’t want to be using such a heavy IDE. I’ve started to use MacDBGp from Blue Static and TextWrangler from Bare Bones Software, and together they provide a lightweight alternative to Eclipse. One of the nice feature of Eclipse however is the auto start of Xdebug debugging by appending XDEBUG_SESSION_START=1 onto the url. There are a couple of plugins for Firefox that allow you to do this in the browser, however there are none for Safari.

So, as of today you can now get “Xdebug Toggler” which allows you to auto start Xdebug debugging from within Safari. At the moment it really is that basic, but I will keep working on it to cater for settings and other features. <disclaimer>Also, this has not been accepted by Apple yet, but hopefully it will. Fingers crossed as this is my first Safari Extension and my JavaScript skills are being worked on!</disclaimer>

You can download the extension here

Once you have installed the extension you will get a bug like icon in the toolbar:


Load the page you want to debug, load up the developer tools (Alt+Command+I) and see that there are no cookies. If you then click the “Xdebug Toggler” button and reload the cookies you will see that there is now the XDEBUG_SESSION cookie that Xdebug looks at, and also the badge of the button as been changed to “1″.


Now that we have toggled Xdebug we can open up MacDBGp and set a breakpoint:


You will also now notice at the bottom left of the screen that MacDBGp is waiting for a connection


Now reload the page you want to debug and you will see the break point being hit in MacDBGp


From this point on it is business as usual to step through the application


This extension also works with all debuggers such as Eclipse PDT, vim and others etc, as it simply sets the cookie needed for Xdebug to know to start the debugging session

Any issues please raise them here

Updated 17-11-2010

I have now updated Xdebug Toggler to cater for the IDE keys. So please download the latest version above. Once you have done this you should be able to enter Safari Preferences and set the IDE Key: