wickywills
7/25/2018 - 1:24 PM

Configuring Xdebug with PHPStorm, Vagrant

Vagrant

First, SSH into your Vagrant box

vagrant ssh

Install Xdebug for your version of PHP

sudo apt-get install php-xdebug

Edit Xdebug config file (location can vary)

sudo nano /etc/php/7.0/apache2/conf.d/20-xdebug.ini

Paste in the below (important - change the remote_host to your local server)

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9000
xdebug.remote_host=192.168.33.10
xdebug.idekey=PHPSTORM

Save, and restart Apache

sudo service apache2 restart

Verify that Xdebug is loaded correctly

php --version

PHPStorm

Select Run > Web Server Debug Validation

Enter a path where the validation script should be created (anywhere - doesn't matter, but somewhere logical)

The URL to the validation script should be your local server URL. For example, since I'm running browsersync, for me this http://localhost:3000/

Now click Validate to ensure everything is working correctly. Fix any errors that are displayed.