Search code examples
phpmacosdebuggingintellij-ideaphpstorm

IntelliJ PHP debugger not connecting


I've set up php 5.6 and Apache on my Mac and have IntelliJ with the php plugin installed (2016.2). The problem is that the IDE doesn't want to connect to the local server.

I've added the following lines to my php.ini:

[xdebug]
zend_extension=/usr/local/Cellar/php56/5.6.24/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = "9000"

and when I run php -v I get:

Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans

and phpinfo() shows

xdebug.remote_enable On On
xdebug.remote_port 9000 9000

But IntelliJ shows:

xdebug.remote_enable 0

I've checked, that I'm pointing to the right php.ini (checked path and other changes appear when the file is edited).

I tried all configurations (including with an IDE key) but nothing seems to work.

Is there a way I can check if the debugging is really working (i.e. is it the IDE not recognizing something or is the server faulty), because at this point I don't know what the problem may be.


Solution

  • The best way is to collect xdebug log for such unsuccessful debug session to see what it has to say. Sometimes debug does not work for you (IDE shows no reaction) but xdebug actually connects somewhere just fine (e.g. another service .. as described below).

    There is a chance that you will have php-fpm running on your computer (that depends on how you installed your PHP -- what tool you have used for that). Php-fpm by default uses the same TCP 9000 port as xdebug does.

    sudo lsof -nP -iTCP -sTCP:LISTEN
    

    Run this command in terminal -- it should tell (after filtering results on 9000 keyword) what services are already listening on that port.

    If it's indeed php-fpm .. then changing xdebug port from default 9000 to any other (e.g. 9001 or any other usually unused port) in both IDE settings + php.ini will solve the issue.