Debugging with PHP Storm

In order to set up Debugging in PHPStorm, you need to tell xdebug your VM how to connect to PHPStorm.

Add a new file in /etc/php/7.2/fpm/conf.d/ within your VM called 21-xdebug-host.ini and add your host IP address to that
Activate xdebug remote debugging in it one of the below
For all: echo xdebug.remote_enable=on | sudo tee -a /etc/php/7.2/fpm/conf.d/21-xdebug-host.ini

Vagrant with Virtualbox: echo xdebug.remote_host= | sudo tee -a /etc/php/7.2/fpm/conf.d/21-xdebug-host.ini

Vagrant with Docker on Linux:  echo xdebug.remote_host= | sudo tee -a /etc/php/7.2/fpm/conf.d/21-xdebug-host.ini

Vagrant with Docker for Mac:

echo xdebug.remote_host=docker.for.mac.localhost | sudo tee -a /etc/php/7.2/fpm/conf.d/21-xdebug-host.ini
echo xdebug.remote_connect_back=0 | sudo tee -a /etc/php/7.2/fpm/conf.d/21-xdebug-host.ini

Restart php-fpm: sudo service php7.2-fpm restart

Your PHP should now configured and you can set up PHPStorm. You'll need to follow the below steps to run the configuration:

Go to the menu to Run -> Debug and click Edit configurations
Debugging with PHP Go to Menu

Debugging with PHP Menu Configuration

Click on the + button on the upper left corner, and select PHP Remote Debug 
Be sure not to go to PHP Remote Debug in the Template section, as you need to create a new one via the plus button.

Debugging with PHP Click Plus then Remote Debug

Name the configuration "Frontastic Debugging".
You don't need to configure anything else in this window. Don't set a filter for IDE connections. You need to install one of the browser toolbars/extensions/bookmarklets linked in the configuration dialog.

Debugging with PHP Name the Configuration

Then you can start debugging, to do this you'll need to follow the below steps:

Activate your new debug run configuration in PHPStorm by clicking the debug button on the bottom right of the window you currently have open, or activate it from the menu, (open the Run -> Debug menu entry again and select your debug configuration).
Debugging with PHP Select Configuration

PHPStorm is now listening to debug connections from your VM.

You just need to tell PHPStorm where you want to start debugging by setting a breakpoint. In the below example, we're just using the index.php for this, but you could set it up for any PHP code in the Frontastic platform, including your custom PHP code.

Open your browser on the Frontastic Page that you want to debug, e.g. and use the browser extension/toolbar/popver… to activate xdebug. Refresh that page, and in your PHPStorm there should be a new window asking you to configure your mappings.
Debugging with PHP Activate xdebug

This is required because xdebug tells PHPStorm paths to files within the Virtual Machine. For instance, the index.php is located under /var/www/frontastic/project/public/index.php, and on your computer it is in a completely different location.

File Path on Server contains the path within your Vagrant Machine. Select the corresponding file on your host below - probably the first preselected file is correct.
You should now be able to debug your PHP code in PHPStorm.

Debugging with PHP Vagrant Machine

‹ Back to Article List

Next Article ›


Still need help? Contact Us Contact Us