Using PDT : Installation : Installing the Zend Debugger

From PDTWiki

Revision as of 10:25, 4 August 2007 by Thierrybo (Talk | contribs)
Jump to: navigation, search

Zend Debugger is a full-featured php debugger engine, an interactive tool that helps you debug PHP scripts. It works with a production and/or development web server and allows you to debug your scripts locally or remotely, from an IDE or the console.

To get the debugger to work you need to install the debugger engine to run in the PHP interpreter (server part), and configure the debugger client to communicate with the engine.

If you only want to debug against a web server (either local or remote), you don't need to add anything to your Eclipse PDT. PDT has a built-in, pure Java debugging client that operates the Zend debugging engine. This is true either for PDT all-in-one package or the PDT plugin only

Note: If you want to debug local PHP scripts, either for command line scripts or for single cgi scripts, you may need to 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).

Contents

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.

Figure. Selecting the Zend Debugger feature‎

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.

Getting the right Debugger Extension Binaries

Debugger Extension can be downloaded from Zend Downloads. You need to download the Debugger Extension packet for the appropriate operating system. Unpack the zipped packet 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 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”).

Figure. The information about the extension directory

Setup php.ini

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”

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 

For linux:

[Zend]
zend_extension=/full/path/to/ZendDebugger.so
zend_debugger.allow_hosts=<comma separated ip_addresses>
zend_debugger.expose_remotely=always 
eaccelerator.enable="0"
  • Disable the Xdebug extension if installed (usually via pear) by commenting out
;zend_extension=/usr/lib/php4/20020429/xdebug.so
  • Also if you have DBG Debugger installed make sure you comment out this line :
;extension=dbg.so

or

;extension=php_dbg.dll


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="

Example:

zend_debugger.allow_hosts=127.0.0.1/32, 192.168.0.0/16

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. If this file is not there, please download it from:

http://downloads.zend.com/support-files/dummy.zip

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.


Figure. phpinfo showing the Zend Debugger extension
  • 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.

Note:

For setting up a debug configuration and doing real debugging with Eclipse PDT, see PHP Source Level Debugging


Up | Back | Next

Personal tools