Setting up Xdebug on Homestead 4.0 (PHP 7)

    $ January 11, 2016

    As Xdebug has been removed from the default Homestead box you now need to install it manually to be able to use it.

    Once you have vagrant ssh-ed to your Homestead VM the first thing you need to do it download the latest compatible version of Xdebug (2.4.0RC3 at the time of writing) and build it:

    cd /tmp
    wget [http://xdebug.org/files/xdebug-2.4.0rc3.tgz](http://xdebug.org/files/xdebug-2.4.0rc3.tgz)
    tar xvzf xdebug-2.4.0rc3.tgz
    cd xdebug-2.4.0RC3/
    phpize
    ./configure
    make
    sudo cp modules/xdebug.so /usr/lib/php/20151012/
    

    You then need to the add your Xdebug config in /etc/php/mods-available/xdebug.ini:

    ; configuration for php xdebug module
    ; priority=20
    zend\_extension=/usr/lib/php/20151012/xdebug.so xdebug.idekey="phpstorm"
    xdebug.remote\_enable=1
    xdebug.remote\_connect\_back=1
    xdebug.remote\_port=9000
    xdebug.max\_nesting\_level=300
    xdebug.scream=0
    xdebug.cli\_color=1
    xdebug.show\_local\_vars=1
    

    Finally you need to add some symlinks so your new config file will be read by PHP:

    sudo ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.0/fpm/conf.d/20-xdebug.inisudo ln -s /etc/php/mods-available/xdebug.ini /etc/php/7.0/cli/conf.d/20-xdebug.ini
    

    Finally restart PHP-FPM and you should be good to go:

    sudo service php7.0-fpm restart
    

    Most of this was based on the helpful Xdebug installation wizard.