[xdebug-general] Re: debugging multi-page applications

From: Damjan Cvetko <zobo[@]scene-si.org>
Date: Wed, 22 Aug 2007 10:28:57 +0200

Derick Rethans wrote:
> On Tue, 21 Aug 2007, Noah Mercer wrote:
>
>
>> Please forgive the newbie-ness of this question; I've only recently
>> started using PHP debuggers at all and XDebug in specific (most of my
>> experience is with Java).
>>
>> Based on my experiences with Java debuggers,. I'd expect a debugging
>> session to go something like this:
>>
>> (1) I set some breakpoints
>> (2) I start the debugger
>> (3) I begin using the app in my web browser
>> (4) At any point when code that has a breakpoint set executes the
>> debug client is triggered and execution halted
>>
>> It doesn't seem to work that way with a multi-page PHP application,
>> though. Imagine a SubmitInput.php page that has a form which calls a
>> ShowResults.php page. If I call
>> http://example.com/SubmitInput.php?XDEBUG_SESSION_START=SOMETHING&KEY=1,
>> the debug client (I'm using debugclient-0.9.0) triggers. I set a
>> breakpoint somewhere in the ShowResults.php page (but none in the
>> SubmitInput page) and I type "run -i 2" the status that comes back is
>> "stopped". And it really does seem to be stopped: If I go to my
>> browser and submit the form the breakpoint in ShowResults.php is never
>> triggered. (And I've tried using xdebug_break() as well as the
>> breakpoint_set command; neither one stops in this scenario.)
>>
>> Is there a way to configure XDebug/debugclient so that I can wander
>> through the pages of my application at will and have it stop on any
>> breakpoint set in any file, regardless of which page I entered the
>> application on? Or will it always go to a "stopped" state when the
>> current script finishes execution?
>>
>
> The debugclient itself does not support this, it is a *very* simple
> client just meant for debugging the protocol interaction. Most other
> clients listed[1] will re-issue breakpoints when a new connection is
> made. It can not be done in Xdebug itself-as you never know to which
> apache process the request goes and there is nothing shared between
> apache processes.
>
> [1] http://www.xdebug.org/docs/remote#clients
>
> It could be an addition to the debugclient client though, but then it
> needs quite a bit of modifications.
>
> regards,
> Derick
>
>
Hello Noah.

Another thing that I think you should watch out here for:
If I understand correctly you have a SubmitInput.php that displays a
form. Then you press SUBMIT
and the browser posts the data to ShowResult.php. This are two scripts
and as PHP works, two requests
and thus two separate worlds. (You need to change your way of thinking
if you worked with java before).

The problem is, that you want to debug ShowResult.php, but the debugger
doesnt kick in, because the second request does not get a
XDEBUG_SESSION_START parameter. So you need to change SubmitInput.php so
it adds a XDEBUG_SESSION_START to the form (either via a hidden
input...) or as a GET parameter.

A far better solution is to use the FireFox XDEBUG helper. You can add
the XDEBUG_SESSION_START cookie with just a click.
https://addons.mozilla.org/en-US/firefox/addon/3960

And as Derick pointed out, using a visual tool (you run windows, quite a
few are available) is much better. If you don't want a full blown IDE, I
suggest the Notepad++ plugin (hehe) or perhaps the XDebugClient...

Best regards.
-Zobo
Received on Wed Aug 22 2007 - 10:29:04 BST

This archive was generated by hypermail 2.2.0 : Mon Jun 25 2018 - 06:00:04 BST