Debugging with PHP Storm
In order to set up Debugging in PHPStorm, you need to tell xdebug your VM how to connect to PHPStorm.
/etc/php/7.2/fpm/conf.d/within your VM called
21-xdebug-host.iniand add your host IP address to that
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=10.0.2.2 | sudo tee -a /etc/php/7.2/fpm/conf.d/21-xdebug-host.ini
Vagrant with Docker on Linux:
echo xdebug.remote_host=127.0.0.1 | 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
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:
Run -> Debugand click Edit configurations
+button on the upper left corner, and select
PHP Remote Debug
PHP Remote Debugin the Template section, as you need to create a new one via the plus button.
Then you can start debugging, to do this you'll need to follow the below steps:
debugbutton on the bottom right of the window you currently have open, or activate it from the menu, (open the
Run -> Debugmenu entry again and select your debug 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.
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 Servercontains the path within your Vagrant Machine. Select the corresponding file on your host below - probably the first preselected file is correct.
‹ Back to Article List