Zend Debugger

Configuring the Zend Debugger at Dreamhost
The Zend Debugger is a PHP extension that allows you to do debugging of PHP scripts via the web server. Zend IDE (5.5) or Zend Studio for Eclipse (6.1). This tutorial has been written for setting up the Zend IDE (5.5). So far it's one of the best PHP IDEs I've used, and it's available for almost all platforms. The server extensions are necessary if you want to debug forms, linked pages or anything using $_SERVER or $_GLOBAL vars. It also allows you to debug these on remote servers with the Zend extensions installed.

WARNING If you configure your site to use your own custom PHP installation, your version of PHP will no longer automatically upgrade when DreamHost upgrades their version of PHP. It is your responsibility to reinstall new versions of PHP! Leaving old versions of PHP installed can possibly be a security hazard!

Install PHP
Use the PHP 5 install script to install PHP into your home directory. I used the first listed and it worked fine. Just to be a rebel I changed the PHP version to the most current at the time (5.2.9). Make this change to the script at your own risk (You've already dismissed the warnings above so this shouldn't get your panties in a bunch). Make sure to modify your .htaccess file to point to php.cgi you just installed. Also, read to the last line. It's quite possibly the most important. :)

Check PHP Install

 * To see if your PHP was successful, create a phpinfo page and run it from your web root directory. Upload a file with the following in it:


 * 


 * and point your web browser to it. If you get a 500 error, MAKE SURE TO READ THE LAST LINE OF THE INSTALL SCRIPT PAGE.


 * If that still doesn't work, go to your newly created cgi-bin directory /home/{USERNAME}/{DOMAIN.TLD}/cgi-bin and run


 * ./php.cgi -i


 * You should get an HTML formatted output of phpinfo. If you don't, there were problems installing PHP and you might have to start over.

Download and Install the Zend Debugger
Download the Zend Debugger (ZendDebugger-5.2.15-linux-glibc23-i386.tar.gz) from Zend. Unpack this file anywhere. This contains the debugger extension and the dummy.php file you will need in a few steps. Copy the appropriate ZendDebugger.so file (the one that matches the version of PHP you have installed. If you used the script above, which installs 5.2.6, you'll copy the file out of the 5_2_x_comp directory) somewhere outside your web tree. I put it in /home/{USERNAME}/ZendDebugger.

Modify Your php.ini File
Add the following lines to your php.ini file. It should be at /home/{USERNAME}/php5/etc/php5/{DOMAIN.TLD}/php.ini. Make sure to replace the full path to your .so file. Add the IP addresses you want to be able to connect to the debugger from. Make sure this is your publicly available IP.


 * zend_extension=
 * zend_debugger.allow_hosts= (Comma Separated)
 * zend_debugger.expose_remotely=always

Check Debugger Installation

 * When you have pointed the php.ini file to the ZendDebugger.so file when you run the phpinfo.php file again from a web browser, it should show you a new extension near the bottom called Zend Debugger. You should see something like this:


 * [[Image:ZendDebuggerPHPinfo.png]]

Copy dummy.php to Web Root
The Zend Debugger uses a dummy.php file as a bootstrap. Whenever you start a debugging session, it looks for http://{WWW.DOMAIN.TLD}/dummy.php?start_debug=1&debug_host=... which configures and enables the debugger. If the web server cannot find Dummy File, the debugger won't work.

Copy the dummy.php file from the tarball and place it in your web root (/home/{USERNAME}/{DOMAIN.TLD}/dummy.php).

Configure the Zend Debugger Client
Go to your Zend Debugger and go to Tools > Preferences > Debug




 * Set Debug Mode to Server
 * Set Debug Server URL to your domain name. Remember the forward slash at the end
 * Set Client IP to 'Customized' and LEAVE IT BLANK (This just about caused me to rip my hair out)
 * Set the Dummy File to 'dummy.php' (Unless you renamed it to something else)
 * Set Client Debug Port to 10000.
 * You can accept the defaults for all the other settings on the Debug tab.

Setup Port Forwarding on your Firewall
If necessary, make sure to forward port 10000 to your local client machine if you are behind a firewall. This is so the debugger can get the messages back to your client.

Troubleshooting
During the connection process it may be helpful to tail the error log to see any connection errors during the config.

Go to your shell account and go to /home/{USERNAME}/logs/{DOMAIN.TLD}/http/

and run

tail -f error.log

This will keep the error log file open so you can see new entries as they appear. It was most helpful to me when troubleshooting this. Type ^C to exit the tail process.

Testing Forms Through the Server Side Debugger
If you want to test forms through the debugger (which is probably why you ran through half this garbage in the first place) you need to make sure that your forms submit to the full URL of the page you are submitting to. Instead of using $_SERVER['PHP_SELF'] you need to write ' http://{WWW.DOMAIN.TLD}/scriptname.php '.

For more information, and a primer on using the debugger on a remote server, check out this great article at IBM.