You are here

Debugging in Zend Studio for Eclipse

Keywords: 

I've been playing with the Zend Studio trial and found it to be really good. Eclipse is an excellent PHP editor but Zend manage to bring some of Eclipse's real power to PHP, that which you can see when writing code in Java.

One useful tool is local debugging. Yet Zend Studio's built in PHP doesn't include extensions such as MySQL, making it not overly useful when you start to use it properly. Now, at this point you should perhaps be running the code on the server and using remote debugging, but what about unit tests? Another excellent feature in Zend Studio is the PHPUnit support. But you can't test MySQL methods as there's no support.

So, here's how to get PHP extensions working in Zend Studio 6 (on Windows, anyway - yes, this is what I use at work..)

Locate the PHP directory inside Eclipse's plugins. You can find this by looking at the preferences for the PHP executable.
Download the binary archive (not installer) of the same PHP version from php.net.
Copy the extensions from the ZIP into the PHP directory.
Edit the php.ini in the same directory and add the line:

extensions_dir = .

(Note: PHP claims to be using c:\windows\php.ini - it is not).
Open the default php.ini from the ZIP you downloaded, and copy all the extension (.dll) lines to your live php.ini.
Also manually add php_mysql.dll and php_mysqli.dll, which are NOT compiled in to Zend's PHP as the example php.ini file says (Zend's php.exe is a special build I believe).

Now try debugging some PHP which uses extensions, and it'll work. Unless you have bugs. Then it'll need debugging.