Debugging with PhpStorm

In order to set up debugging in PhpStorm, you need to allow Xdebug running on your Frontastic Machine to connect to PhpStorm.

If you're using Frontastic CLI, you can do this by using  frontastic xdebug. Alternatively, you can set up the port forwarding yourself by using  ssh <user>@<host> -R 9003:localhost:9003.

Optionally, you can set the debug connection to start automatically when you make a request. To do this, open the Xdebug config file and update the config setting to set xdebug.start_with_request to 1. Then SSH into your development machine and use vi $(php --ini | grep xdebug | sed 's/,//') to edit it. If you do this update, remember to restart php-fpm using sudo service php7.4-fpm restart.

If you run into any problems you can have a look at the Xdebug log at /tmp/xdebug

Now, your PHP should be configured and you can set up PhpStorm. You'll also need to follow the below steps to run the configuration:

Go to the menu to Run, select Debug, and click Edit configurations
Debugging with PHP Go to Menu

Debugging with PHP Menu Configuration

Click on the add icon button on the upper left corner, and select PHP Remote Debug
Don't go to the PHP Remote Debug in the Template section, as you need to create a new one via the add 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 menu again, select Debug, and then select your debug configuration).
Debugging with PHP Select Configuration

PhpStorm is now listening to debug connections from your Frontastic Machine.

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, for example, 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 Frontastic 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 Frontastic 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