ActiveState Powered by ActiveState

ActiveState Community


Toggle PHP Debugging

Posted by scottpederick on 2007-03-28 22:33
OS: All / Any

Hi,

Not sure if this is the best place to post this but thought it might be handy for other users debugging using Firefox.

Create a new bookmark and paste in the following as the location:

javascript:(function(){var exp = new Date(); exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 1));var c = document.cookie.indexOf('XDEBUG_SESSION');if (c==-1) { document.cookie = 'XDEBUG_SESSION=1;expires=' + exp.toUTCString() + ';path=/'; } else { document.cookie = 'XDEBUG_SESSION=;expires=expires=Thu, 01-Jan-70 00?? GMT;path=/'; }})()

This will toggle the XDEBUG_SESSION cookie. On the next page fetch (refresh or AJAX) the debugging will be set.

Scott

ToddW | Thu, 2007-03-29 08:07

I'm assuming you can also turn it off (stop debugging requests) in a similar fashion, by removing the XDEBUG cookie if it's set?

scottpederick | Thu, 2007-03-29 14:22

Yeah - it's a toggle. Turns it on if it's off and off if it's on.

Heh
ToddW | Thu, 2007-03-29 14:23

Should learn to read I guess :D

ToddW | Wed, 2007-04-04 07:49

There is this Firefox extension as well:

https://addons.mozilla.org/en-US/firefox/addon/3960

Cheers,
Todd

scottpederick | Wed, 2007-04-04 14:19

Ah - much better.

The downside of that script is you have to try and remember the current debug state since there's no indicators. One more bit of information to hold in your head that pushes out something useful like walking, or breathing.

Cheers,

Scott

PenguSven | Thu, 2007-08-16 22:02

i wrote these two before i found this thread. might be useful to someone:
just make them a bookmark. they'll reload the current page with debugging turned on or off, respectively. works in FF2 and MSIE6.

/* start debugging */
javascript:if(location.href.search(/\?/) > 0){location.href=location.href.replace(/\?/,'?XDEBUG_SESSION_START=debug&');}else{location.href=location.href+'?XDEBUG_SESSION_START=debug';}

/* stop debugging */
javascript:if(location.href.search(/\?/) > 0){location.href=location.href.replace(/\?/,'?XDEBUG_SESSION_STOP&').replace('XDEBUG_SESSION_START=debug','');}else{location.href=location.href+'?XDEBUG_SESSION_STOP';}

cheesegrits | Mon, 2008-01-07 14:58

I feel like a dork having to ask this ... but is there any way to do this in IE? I've been using the FF toggle for a while, and it's a life saver ... but I'm having to (*gasp*) use IE7 for compat testing a lot now, and could really use the same feature.

-- hugh

jeffg | Thu, 2008-05-08 12:07

Don't the bookmarklets work in IE?

--
JeffG

-->