This article will discuss how to configure xDebug (php debugging) to work in NetBeans with Denwer installed. An article for beginners, just like me. I decided that if I killed a couple of days for setting up, it could save someone time.
Immediately make a reservation - the question of using the Denwer package is controversial. Perhaps it’s better to use something like wamp or xampp, but I still like Denwer myself (picks up virtual hosts myself) and despite the fact that the project hasn’t been updated for some time, I will live another 1.5-2 years. Yes, and most articles for beginners usually start "put Denwer."
So, the usual sequence of configuration actions is:
- Downloading the correct version of the dll xDebug;
- We put it in the right directory php;
- We make the necessary settings in php.ini;
- Configure NetBeans;
Downloading the correct version of the xDebug dll
The library should be downloaded from
xdebug.org . The problem is choosing the right version of the dll.
Here, for example, is a list of binary versions 2.2.0 for Windows:
- PHP 5.2 VC9 (32 bit)
- PHP 5.2 VC9 TS (32 bit)
- PHP 5.3 VC9 (64 bit)
- PHP 5.3 VC9 (32 bit)
- PHP 5.3 VC9 TS (64 bit)
- PHP 5.3 VC9 TS (32 bit)
- PHP 5.4 VC9 (64 bit)
- PHP 5.4 VC9 (32 bit)
- PHP 5.4 VC9 TS (64 bit)
- PHP 5.4 VC9 TS (32 bit)
Usually, in order to determine the required version, it is enough to make a php-file with a call to the
phpinfo () function on Denwer on one of the virtual hosts. For example,
index.php<?php
phpinfo();
?>
Open this page in a browser, click “view page source code”, copy everything to the clipboard, paste it all into
xdebug.org/wizard.php and the xDebug helper will prompt the necessary library. But the Denwer package includes php version 5.3.3, compiled with Visual C of version 6, which is no longer supported by xDebug, which is what the helper reports, refusing to prompt the correct version of the dll.
There is a choice of 2 options:
- update php (perhaps the best option)
- to figure it out
Let us analyze the second option. The choice of xDebug version depends on the following php parameters:
- php version
- compiler version of visual c (6/9)
- did your version of php compile with the parameter Thread Safety = enable or disable
- version of the platform under which php was compiled (32/64 bit)
All this information can be independently obtained from the output of the
phpinfo () function. So, I have the latest build of Denwer with php version 5.3.3, VC6, TS, 32 bits. The latest version of xDebug that suits me is 2.1.2 (PHP 5.3 VC6 TS (32 bit)). dll file -
php_xdebug-2.1.2-5.3-vc6.dllWe put it in the right directory php
The library should be placed in the ext subdirectory of the php directory. With a standard installation, this is: c: \ WebServers \ usr \ local \ php5 \ ext \
')
We make the necessary settings in php.ini
At the end of the file php.ini, which when installed Denwer is by default located in c: \ WebServers \ usr \ local \ php5 \, you need to add the following lines:
zend_extension = c:\WebServers\usr\local\php5\ext\php_xdebug-2.1.2-5.3-vc6.dll
xdebug.remote_enable = on
xdebug.remote_handler = dbgp
xdebug.remote_host = localhost
xdebug.remote_port = 9000
As for the pair of parameters, I would like to comment:
zend_extension - the path to your xDebug library can be either through a real disk (I have C :) or through a virtual disk, for example Z :. Also for the version of php 5.2 this parameter should be called
zend_extension_ts .
xdebug.remote_port - the port on which the debugger will hang. He, of course, should not be busy. If busy - you can choose any free.
At the moment, xDebug should already connect to php - this can be seen through
phpinfo () , a block will appear at the end of the first table with something like this: “Zend Engine v2.3.0, Copyright © 1998-2010 Zend Technologies
with Xdebug v2.1.2, Copyright © 2002-2011, by Derick Rethans »
Configuring NetBeans
In NetBeans, in the Tools / Options / PHP menu, you must specify the path to the php interpreter - I have
c: \ WebServers \ usr \ local \ php5 \ php.exe . And finally - on the “Debug” tab, specify the debugger port that we wrote earlier in
php.ini . I have - 9000, respectively.
Everything can set breakpoints and enjoy the configured system.