Search code examples
phpvagrantphpstormxdebughomestead

PhpStorm and XDebug on Vagrant Homestead


I'm on Windows and I'm trying to debug a Web application (hosted with Vagrant/Homestead) using PhpStorm through XDebug. I tried many configurations but I can't get things working. The PhpStorm XDebug setup is pretty common.

This is the current xdebug configuration:

vagrant@homestead: /etc/php/7.0/cli/conf.d/20-xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable = on
xdebug.remote_connect_back = on
xdebug.idekey='PHPSTORM'

In the IDE "Start listening for PHP debug connections" it's turned on. When I attempt to start debugging a new chrome tab opens and the URL ends, for example, with ?XDEBUG_SESSION_START=16588 but the debugger doesn't run and this is what the IDE says:

enter image description here

Also, netstat says the port 9000 is still listening. Any idea?


Solution

  • You are changing the 20-xdebug.ini file for the Command Line Interface (CLI). Instead you need to change the /etc/php/7.0/apache2/conf.d/20-xdebug.ini for the Apache settings, since you are using Chrome.

    UPDATE

    I'm not sure of the differences between Apache and Nginx (which may be /etc/php/7.0/fpm/conf.d/20-xdebug.ini), but here is how I got it working with a VirtualBox VM running Apache, on a Windows computer.

    Settings for 20-xdebug.ini:

    zend_extension=xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_host=192.168.1... (your windows IP address within your network)
    xdebug.remote_port=9000
    xdebug.autostart=1