37

I installed Xdebug and all was fine, until suddenly it stopped working. phpinfo() gives a nice XDebug output with all variables.

php -m | grep deb

also gives twice XDebug (for Zend and PHP), so again looks just fine. My php.ini has these lines:

zend_extension=/usr/lib/php5/20090626/xdebug.so
;extension=xdebug.so
xdebug.remote_host=localhost
xdebug.remote_enable=on
xdebug.remote_port=9001
xdebug.remote_handler=dbgp
xdebug.remote_connect_back=1

And yet, when running this code with should check XDebug (from Netbeans docs) it's just stuck. So No IDE is working with XDebug.

<?php
$address = '127.0.0.1';
$port = 9001;
$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);

Also, according to XDebug installation, I went twice throught the steps. What is wrong with my config? Thanks.

Xerkus
  • 2,695
  • 1
  • 19
  • 32
valk
  • 9,363
  • 12
  • 59
  • 79
  • even after adding xdebug.remote_log="/tmp/xdebug.log" and restarting Apache2, and running an app the log is empty... – valk Apr 02 '12 at 05:50

7 Answers7

17

At the end, left with only two solutions - to reinstall the Ubuntu OS or to install a new VM especially for xdebug, I'm going for the second one. Funny thing is, everything was working according to the "RTM" (f=freaking). One thing that I couldn't figure out is how to read the logs for XDebug in order to understand where the real problem is.

UPDATE

After some struggling, I deleted every single line related to xdebug from every php.ini that I had. And moved these lines to /etc/php5/conf.d/xdebug.ini. Restarted Apache, and then PHPStorm, and it works. P.S. in the middle, I tried to install xdebug with pecl, from github, and the standard Ubuntu version. I think the one that I compiled is currently working. And.. the log gets updated as well.

;xdebug configuration
zend_extension = /usr/lib/php5/20090626/xdebug.so
xdebug.remote_host = 127.0.0.1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_mode = req
xdebug.profiler_enable=0
xdebug.profiler_enable_trigger=1
xdebug.remote_autostart=1
xdebug.idekey=PHPSTORM
xdebug.remote_log="/tmp/xdebug.log"
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
valk
  • 9,363
  • 12
  • 59
  • 79
12

On your server, try this command:

$ netstat -anp | grep CLOSE_WAIT

Any :9000 entries will give you XDebug troubles; consider kill -9 <pid>.

Derek Illchuk
  • 5,638
  • 1
  • 29
  • 29
  • 2
    For those not completely familiar with linux, the PID on ubuntu for me using this command was the last column: 3131/apache2 PID = 3131 – espradley Jul 21 '17 at 16:31
  • I know it's an old post , but I had to use sudo with netstat to see the . There is already a warning : (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) – Sofien Joulak Dec 01 '22 at 20:19
2

I had this problem too on Ubuntu after updating php. For me, turning on html errors in php.ini got xdebug with Netbeans to work again ...

sudo vi /etc/php5/apache2/php.ini
display_errors = On
html_errors = On

And restart apache:

sudo /etc/init.d/apache2 restart

http://ubuntuforums.org/showpost.php?p=9592364&postcount=14

Michael Gorham
  • 1,234
  • 2
  • 16
  • 24
1

I checked my

netstat -anp

output and found out that there were number of open sockets (in XDebug port range) by master process on my remote machine [running xDebug].

Killing the 'master' process solved the problem for me.

Seemed like a port overrun situation for me. Thought the information might be useful to some.

Siddharth Tyagi
  • 395
  • 2
  • 8
0

Check are you putting breakpoints to the right file. Find first file where script enters (front controller). On symfony there can be more than one for example.

Darius.V
  • 737
  • 1
  • 13
  • 29
0

In my case after update xdebug to 3 version I just put/set php.ini config

error_reporting=E_ALL
display_startup_errors=1
display_errors=1

and then command php -v show all warnings and errors. In my case:

Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
GetoX
  • 4,225
  • 2
  • 33
  • 30
0

check port is not occupied, check netbeans is configured to listen to that port(i see you have 9001, 9000 is default usually)also when i debug with eclipse i have to "terminate and relaunch" the debug session every now and then since it stops working, never under stood why, i suspect some sort of expired debug session

max4ever
  • 11,909
  • 13
  • 77
  • 115