Search code examples
phpxdebug-3

php7.4 Xdebug xdebug.mode = debug is not working for me


I have installed Xdebug on a Ubuntu 20.04 system. I followed this documentation , which I found to be quite well written, and got everything installed per the specs. (I used apt rather than yum, and placed the .so file into /usr/lib/php/20190902 folder rather than the document's example.)

In that document, there is a reference to adding to the php.ini file (I added to /etc/php/7.4/apache2/php.ini and /etc/php/7.4/cli/php.ini files). Since the article doesn't specifically mention "sections" of the .ini file, I put them within the [PHP] section. (This is consistent with the remark about putting right before the Quick Reference bit.) I restarted Apache2 and the phpinfo() output now includes Xdebug, which it did not include before. All well and good.

The trouble I'm having is that although I set xdebug.mode = debug in the php.ini files, the phpinfo() output tells me that xdebug.mode is set to develop. Consequently, Step debugger shows as Disabled in my configuration. I cannot see why.

These are the lines I've added to each of those php.ini files:

zend_extension=xdebug.so

#zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.mode=debug,develop,trace

[xdebug]
xdebug.remote_host=localhost
xdebug.remote_connect_back=0
xdebug.remote_enable=1
xdebug.remote_port=9900
xdebug.idekey="PHPSTORM"
xdebug.remote_log="/tmp/xdebug.log"
xdebug.remote_handler=dbgp
xdebug.show_error_trace = 1
xdebug.log_level = 7
xdebug.start_with_request=yes
xdebug.mode=debug,develop,trace

And here are the key excerpts from the phpinfo() output:

enter image description here

On a whim, I tried placing all of those settings also within a new section of php.ini which I called [xdebug]. When that didn't work, I tried [Xdebug]. I restarted Apache2 after each attempt, but the symptom never changed.

What might I be missing?


Solution

  • For me, being on Ubuntu 22, PHP 8.1 and xdebug 3.1.2, the solution was to edit not the php.ini file but the xdebug.ini. For example :

    sudo nano /etc/php/8.1/cli/conf.d/20-xdebug.ini
    

    After this a restart for apache

    sudo service apach2 restart 
    

    Then I was able see the changes in phpinfo and finally connect to PHPStorm debugger.