Using PDT : Installation : Installing the Zend Debugger
Zend Debugger is a full-featured php debugger engine. It is an interactive tool that allows you to debug PHP scripts locally or remotely, from an IDE or from the console.
To use the debugger engine you must install it to run in the PHP interpreter.
PDT has a built-in debugging client that operates the Zend debugging engine. The debugger client must be configured to communicate with the debugger engine. This is true for both the PDT all-in-one package or the PDT plugin only
Alternatively, if you want to debug only local PHP scripts, you may install the Zend Executable Debugger plug-in. The Zend Executable Debugger plug-in adds a local PHP 4 and PHP 5 binary ready for debugging. This is useful if you do not have a PHP binary locally or cannot use your local php binary because it is not suitable for debugging (depends on compile options, ...) or want to use this debugger without the PDT (with PHPEclipse, for example).
Installing Zend Debugger client
To install the Zend Executable Debugger plug-in using the Update Manager, follow the instructions I provided earlier to set up a new update site using the following information:
PHP Development Tool (PDT) UPDATE URL: http://downloads.zend.com/pdt
Please note that the Zend Executable Debugger is not available from the Eclipse site’s PHP update URL listed in my earlier post. Instead, you must use the Zend update URL (listed here) to install the debugger. When installing, if you already have the PDT installed, simply choose to install only the Zend Debugger.
Configuring for Mysql
The Zend debugger client will not work with MySQL statements. To get MySQL interactions working you must configure the PHP binary included with the Zend Debugger client to use an external copy of the php_mysql.dll or php_mysqli.dll file.
- Open the PDT plugin folder. For example:
- Add the following 4 separate lines to the end of the php.ini you find there:
extension_dir = "C:/full path to external php server/php/ext"
include_path =".;C:/full path to external php server/php;"
- An example with WAMP would be:
extension_dir = "C:/WWW/wamp/php/ext"
- Then you need to copy the following files to the PDT plugin folder:
’php_mysql.dll’ from the folder ‘C:\WWW\wamp\php\ext’
’php_mysqli.dll’ from the folder ‘C:\WWW\wamp\php\ext’
’ libmysql.dll’ from the folder ‘C:\WWW\wamp\php’
Now the Zend debugger in Eclipse also works for MySQL statements!
Installing Zend Debugger server
Make sure you download the appropriate Zend Debugger binaries for your OS and your release of PHP (from 4.3.x up to 4.4.x and from 5.0.0 up to 5.2.x). Curently it is available for Mac OS X, Linux 32/64bits and Windows 32 bits.
Note: Leopard's Apache build is now 64-bit on 64-bit Intel Macs while ZendDebugger.so is a 32 bit-only binary. A work-around until Zend release a 64-bit version is to start Apache in 32 bit mode: sudo arch -i386 /usr/sbin/httpd
Getting the right Debugger Extension Binaries
Debugger Extension can be downloaded from Zend Studio Downloads (The old site, which doesn't include php 5.3 is at: Zend Downloads). Download the "Studio Web Debugger" zip file. From this you need to extract a Debugger Extension library for the appropriate operating system and architecture. Unpack the zipfile and take the dll (or so) file which matches the PHP version you have currently running. E.g. for PHP 5.1.2 the correct file is ZendDebugger.so (ZendDebugger.dll for Windows) inside 5_1_x_comp directory. Then read the following Section, “Find the extension directory” to find out the right destination location for the file.
Find the extension directory
The best way to find out is via the “phpinfo()” command. Create a PHP-file called phpinfo.php with the following content:
<?php phpinfo(); ?>
and start it via your web browser. Then search for “extension_dir”. The right column shows the path to the directory where you have to place the ZendDebugger.dll/so (see Figure “The information about the extension directory”).
Where is the php.ini which needs to be set up?
The simplest way to find out the path of the php.ini is again with the help of the phpinfo function as described in Section “Find the extension directory”
The resulting output shows the path of the php.ini file within the topmost header. See Figure “Get the php.ini path”
- Now open php.ini and search for “implicit_flush”, and set it to “On”.
; this is to see output while debugging implicit_flush = On
- The output buffering functionality must be switched off to see debug output, too.
Note: But remember that output buffering is necessary to allow you to send header lines (e.g. cookies) even after you sent body content. So if you get an error message like "Warning: Cannot modify header information - headers already sent", you have to restore output_buffering to its original value.
; this is to see output while debugging output_buffering = 0
- For Windows, copy the following lines into php.ini (they can go at the end of the file).
[Zend] zend_extension_ts=/full/path/to/ZendDebugger.dll zend_debugger.allow_hosts=<comma separated ip_addresses> zend_debugger.expose_remotely=always
[Zend] zend_extension=/full/path/to/ZendDebugger.so zend_debugger.allow_hosts=<comma separated ip_addresses> zend_debugger.expose_remotely=always
- You can also use the Zend Optimizer and the Zend Debugger in parallel with the help of the Zend Extension Manager (part of the the free Zend Optimizer). Use (and adjust) the following php.ini settings for windows (I am not sure of the correct syntax for linux).
[Zend] zend_extension_ts="/full/path/to/ZendExtensionManager.dll" zend_extension_manager.optimizer_ts="/full/path/to/ZendOptimizerRoot/lib/Optimizer-x.x.x"
[Debugger] zend_extension_manager.debug_server_ts="/full/path/to/ZendDebuggerInstallation" ;zend_debugger.expose_remotely=always zend_debugger.expose_remotely=allowed_hosts
Have a look at the directory structure of the lib/Optimizer-x.x.x directory and organize your debugger installation the same way. Here's an article explaining the details.
Real installation example:
[Zend] zend_extension_ts="C:\Programme\Zend\ZendOptimizer-3.3.0\lib\ZendExtensionManager.dll" zend_extension_manager.optimizer_ts="C:\Programme\Zend\ZendOptimizer-3.3.0\lib\Optimizer-3.3.0"
- Disable eAccelerator if it is installed and enabled:
- Disable the Xdebug extension if installed (usually via pear) by commenting out
- Also if you have DBG Debugger installed make sure you comment out this line :
Note: You may have different experiences loading both zend_extension, DBG, eaccelerator or other cache engines changing their order of appearance within php.ini but usually they prevent Apache to properly start.
- Type the IP address of the machine you are running the Eclipse PDT Client in the directive: "zend_debugger.allow_hosts="
Make sure you restart your web server after such change.
- Copy the file named dummy.php in the server's document root directory.
The file is inside the "Debugger Extension" archive (same link above) :
Place the downloaded file in the web server root directory.
- Finally restart web server
Test Zend Debugger Installation
When you have done all steps, restart your web server and again submit the phpinfo function as described in Section “Find the extension directory”. Search the browser output for “Debugger” and you should find a section like you can see in Figure “phpinfo showing the Zend Debugger” at the top of the output and a Zend Debugger section at the bottom.
- Check that you have no firewall rule that prevents communication between client and server.
- As the Zend Debugger relies on cookies, check that they are enabled in your external browser or Mozilla if you use internal browser on Linux.
For setting up a debug configuration and doing real debugging with Eclipse PDT, see PHP Source Level Debugging