Search

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Vagrant xDebug PHPStorm – How to : Installation and Configuration guide

In this tutorial, we will review how to get configured Vagrant xDebug PHPStorm – all three applications together.

If you are new to Vagrant, please consider watching the following articles as prerequisites to this one:

Let’s start Vagrant xDebug PHPStorm

So, basically, when you have the Vagrant configured with the provisioning in place, all you should do is to create an xDebug config file within “/environment” directory and name it “xdebug.ini”

touch xdebug.ini

Then add the basic xDebug configuration into the file:

zend_extension=xdebug.so 
xdebug.remote_host=10.0.2.2 
xdebug.remote_enable=1

!IMPORTANT – make sure to replace IP from 10.0.2.2 to an actual IP address of your Vagrant. Login to Vagrant with the command

vagrant ssh

And execute the command below to find the actual IP address

netstat -rn

Once the config file is created and updated with an actual IP address of Vagrant box, go ahead and add the following new records to your provisioning config file “/environment/bootstrap.sh”:

apt install -y php-xdebug 
cp /var/www/html/environment/xdebug.ini /etc/php/7.2/cli/conf.d/20-xdebug.ini 
systemctl restart apache2

Reload Vagrant for the new changes to take effect with the command:

vagrant reload --provision

If everything is done properly, the only thing that you need to do is to configure your PHPStorm and Install Chrome or Firefox extension for xDebug.

PHPStorm settings:
xdebug phpstorm

Chrome and Firefox plugins:

When everything is configured, make sure you launch xDebug for PHPStorm and in your Browser. Then set a red dot on the PHP code line that you want to profile and start executing the page/file.

That’s it!

Other materials to consider:

Leave a Reply

Alex Kostritsa

About author
My name is Alex. For more than 10 last years I've been worked in the role of Project Manager in an Agile environment. I have experience working with different business domains including e-commerce, social networks, and gambling. As a Software Manager, I try to keep myself tuned and continue self-development.
View all posts (20)
  • Odessa, Ukraine