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”
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
And execute the command below to find the actual IP address
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.
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.
Other materials to consider:
- Config files example on GIT: bootstrap.sh & xdebug.ini
- How to Install Vagrant on Windows 10?
- Vagrant Provisioning – Installing PHP and MySQL
- Vagrant official website
Leave a Reply