Seva's notes

Wisdom, Awareness, Responsibility :)

Archive for the ‘mozilla’ Category

Debug PHP and JavaScript simultaneously

leave a comment »

Yesterday me and Roy had a brainstorm session on future Zend Neon (Commercial version of PDT) and ATF integration and “occidently” found a way of debugging of an URL with both Zend’s PHPand Mozilla‘s JavaScript debuggers in one session.

Surprise! It’s possible with neither patching nor hacking. I’m not going to show the exact steps of this, but the idea is very simple:

As you probably don’t know, to debug URL on a server which has Zend Debugger installed it’s enough to pass several simple parameters with the HTTP request (either in the query string or as cookies), like client IP and port, debug type etc., to start the debug session. Afterwards the debugger contacts the client machine, where a Neon’s Debug Daemon listens for incoming connections. The Daemon then raises up a new Launch Configuration.

When Neon’s Debug URL action is executed, it just appends the needed debug parameters to the passed URL and sends the updated URL either to the browser. Just grab this URL and start Mozilla JavaScript Debug Launch with it!

As the result 2 simultaneous launch configurations will start; the first activated session will be PHP’s one and then, after the browser will start receiving content from the server, JavaScript’s one will come into the picture.

Voila!

Moreover, if you enabled all-pages (cookie based) PHP debugging, it will go further with your AJAX (AJAH/AJAJ) requests!

Now the only problem 🙂 is you cannot set breakpoints of both PHP and JavaScript types in the PHP source file, since it doesn’t match the final responce which will be passed to the browser, so you should enable the option to suspend the JavaScript execution immediately after it starts to add breakpoints to the responce HTML source.

Written by Seva

2007-10-20 (October 20) at 12:54:00