3
votes

I want to debug PHP from NetBeans 7.1. My web server is IIS. I've first of all discovered that NetBeans tries to use XDebug, downloaded it, copied DLL to appropriate folder. Now I would like to know how to configure it properly.

The online php config analyser gave me following advices:

  1. Download php_xdebug-2.1.4-5.3-vc9-nts.dll
  2. Move the downloaded file to C:\Program Files\PHP\v5.3\ext
  3. Edit C:\Program Files\PHP\v5.3\php.ini and add the line
  4. zend_extension = C:\Program Files\PHP\v5.3\ext\php_xdebug-2.1.4-5.3-vc9-nts.dll

Restart the webserver

Ok, everything is clear, except in which section of php.ini to put the line. I'm in doubt.

On the other side, Netbeans complains:

No connection from xdebug was detected within 224 seconds. The reasons could be that xdebug is not installed or not properly configured. Be sure that your php.ini file contains these entries:

xdebug.remote_enable=on

xdebug.remote_handler=dbgp

xdebug.remote_host=localhost (or hostname)

xdebug.remote_port=9000

And again, in which section of php.ini to put these lines?

5
anywhere in php.ini should be ok, i've appended such stuff at the very end to better find it. there are xdebug settings for php.ini like e.g. the port it uses and you may set those settings, too. your netbeans complains about exactly those missing settings.Hajo
Still no result. It tries to open localhost/PHP/index.php?XDEBUG_SESSION_START=netbeans-xdebug in default browser and the response is HTTP 404.0 - Not Found.Paul
your iis is up and running on localhost? the php path does exist?Hajo
I tried to run simple PHP pages composed in Notepad - they work. Now I'm trying to use NetBeans.Paul

5 Answers

2
votes

You can add xdebug lines anywhere to the php ini file most likely at the end. To check if xdebug is correctly installed check phpinfo function and the debugclient. You can get the debugclient at the xdebug homepage: http://xdebug.org/docs/install. When you start it with the switches -i 9000 -r 9000 it should connect to xdebug after then you can verify it with netstat -an | grep 9000. Then you can load an example webpage and look at the output of the debugclient. Just in case check your xdebug log. When it works with the debugclient you have a good proof and you can make it work with your IDE. This help me a lot: http://forums.netbeans.org/topic1513-30.html. You can also check this script if the xdebug is listen to port 9000:

<?php 
     $address = '127.0.0.1'; 
     $port = 9000; 
     $sock = socket_create(AF_INET, SOCK_STREAM, 0); 
     socket_bind($sock, $address, $port) or die('Unable to bind'); 
     socket_listen($sock); 
     $client = socket_accept($sock); 
     echo "connection established: $client"; 
     socket_close($client); 
     socket_close($sock); 
?>

It didn't work for me but give it a try? I've lighttpd and xdebug on my virtual machine and I use a reverse shell with my remote server. I use Komodo IDE.

2
votes

You can add it anywhere in the file. If you search for "extension" or ".so" or ".dll" I'm sure you will find an example in the php.ini file. I am not too familiar with Windows, but on linux, typing "php -m" into the terminal lists all the currently loaded modules. Xdebug should be listed twice, once under PHP and once under Zend.

Example

; php -m

Outputs ...

[PHP Modules]
mysql
mysqli
curl
xdebug

[Zend Modules]
xdebug

A couple of things you can check to help get through this is output the phpinfo() on a webpage and check that the php.ini you are editing is the one being loaded. It's listed under "Default Configuration File"

Also after you restart your server. Check the server log to make sure there aren't any errors in the configuration file.

I have xDebug running in Netbeans, but I don't use the configuration they provide in their error message. I only added one line to my .ini file:

zend_extension=<path_to_extension>/xdebug.so

Zend extensions (at least with my setup) require a full path so check that the path is full (which it looks like yours is) and that it is correct.

You could also try putting the extension in your default extension folder listed in phpinfo under "extension_dir".

1
votes

I had a similar issue and came across a post to fix the problem. My html form (testform.html) was calling a php script (runQuery.php) and Netbeans could not break at the set break points.

After checking all the configuration settings in php.ini and Netbeans by searching on forums like this one, I discovered that netbeans will only break on the break points if the Index file for the project is a PHP file. This is very important otherwise you will spend hours trying to figure out why break points are not working.

In Netbeans go into the File/Project Properties/Run Configuration and check that the Index file is a PHP file. In my case I changed my index file from testform.html to testform.php and it worked, I was able to break on break points.

Yasar.

0
votes

If you have tried the xdebug thing in php.ini and it didn't work, I had the same problem. I read online help to no avail. Later I noticed that my url was displaying the wrong address:

localhost/todolist/web/web/index.php?XDEBUG_SESSION_START=netbeans-xdebug

when it was supposed to be

localhost/todolist/web/index.php?XDEBUG_SESSION_START=netbeans-xdebug

I corrected that and got it working.

0
votes

I was having a similar issue and thanks to J.Money's advice of running PHP -M, I worked out the problem is that my path had a space in it and hence needed double quotes around it:

To solution is to change:

zend_extension = C:\Program Files\PHP\v5.3\ext\php_xdebug-2.1.4-5.3-vc9-nts.dll

To:

zend_extension = "C:\Program Files\PHP\v5.3\ext\php_xdebug-2.1.4-5.3-vc9-nts.dll"

I have also logged this as a bug: http://bugs.xdebug.org/view.php?id=922