Tuesday, 15 July 2008

Debugging PHP using Eclipse and DBG

I've recently got back in to writing PHP code, and decided I would like to use an IDE with integrated debugger, like I am used to with C, C++, C#, Java and other languages.

Having reviewed the available IDEs that support PHP, I chose Eclipse - mostly because it supports a variety of languages, and I wanted to see if it was as good as people said.

I installed Eclipse from www.eclipse.org onto a Windows XP machine. Then I installed PHPeclipse from www.phpeclipse.net.

I then installed the DBG PHP debugger from dd.cron.ru/dbg/onto my Linux server.

I had some difficulty getting debugging to work. Firstly, I had to update PHPeclipse from the nightly build (this is done in Help, Software Updates), and make sure only DBG support was included (only one debugger is allowed to be installed at a time). Secondly, I found remote debugging did not work at all - all attempts to debug gave the message "failed to establish connection to client host on localhost:10001".

It turns out that DBG requires HTTP_SERVER_VARS to be set in order to find out the IP address of the machine running Eclipse, but CentOS 5 disables this variable by default. The solution was to add
register_long_arrays On
to php.ini to re-enable the variable.

It is a little too early to give my impressions of Eclipse - I haven't really found my way about it properly yet. But debugging PHP now (mostly) works, and that in itself is really useful.

No comments: