Debugger Setup in Vagrant
  • 15 Sep 2020
  • 1 Minute To Read
  • Print
  • Share
  • Dark

Debugger Setup in Vagrant

  • Print
  • Share
  • Dark

This article describes how to setup debugging in your development environment.

To configure debugging for old version of the VM prior 91, see Debugging Setup for VM Prior Version 91.

Installing the Xdebug Module

To install Xdebug run:

sudo -i apt-get install php-xdebug

Enable Xdebug:

Make sure that Xdebug is enabled in your php.ini file.

In your virtual machine, navigate to /etc/php/7.2/mods-available/xdebug.ini and set:

 # This is needed to prevent max recursion exeception when Twig templates are very complicated

Enable module and restart PHP-FPM:

Run the following command from the command line:

sudo -i bash -c "phpenmod xdebug && systemctl restart php7.2-fpm.service"

To disable:

sudo -i bash -c "phpdismod xdebug && systemctl restart php7.2-fpm.service"

Define servers in PHPStorm:

In PHPStorm go to Settings (Preferences->Languages & Frameworks)->PHP->Servers Add a new Server using (+) with the following values:

  • Name: Any name, e.g. (it is used in CLI below)
  • Host: ~^zed\.de\..+\.local$
  • Check “Use path mappings”
  • Set “Absolute path on server” to: /data/shop/development/current

For Yves, add another one using ~^www\.de\..+\.local$ as Host.

Host names changed
Starting from VM91 a regular expression is used to define host names and is forwarded to PHPStorm. This allows to support custom domains in your setup

Configure Debugger

In PHPStorm, go to: Settings (Preferences->Languages & Frameworks)->PHP->Debug -> Under External connections increase Max. simultaneous connections to 2.

This is necessary to allow debugging Zed through a connection from Yves.


To debug from PHPStorm:

  • Go to Run->Edit Configurations…

  • Add a PHP Remote Debug using (+)

  • Name: any name you like

  • Servers:

  • Ide Key(session id): PHPSTORM

  • Click on Listen for PHP Debug Connections button (in the picture)

  • Click on Debug button (in the picture), you should get the message: “Waiting for incoming connection with IDE key ‘PHPSTORM’”

Debugging Console Commands:

In order to trigger Xdebug in CLI, prepend environment variables to commands like

XDEBUG_CONFIG="remote_host=" PHP_IDE_CONFIG="" vendor/bin/console <command>

The serverName variable should be equal to the server name used when defining servers in PHPStorm.

Xdebug Google Chrome helper (Optional):

As a Chrome user, you can install the “Xdebug helper” extension. Under options set the IDE Key to “PhpStorm”. Everybody else can thengenerate bookmarklets with IDE key set to “PhpStorm” (Debugger bookmarklets generator for PhpStorm).

Was This Article Helpful?