Debugging with Xdebug

Xdebug is the tool number one for our daily work as a developer. It's very easy to make it work with our MGT Development Environment. Just follow the 3 steps to get it work.

Debugging with Xdebug

Step 1: Login with ssh into container

ssh root@127.0.0.1
Password: root

Step 2: Enable Xdebug and set remote_host in php.ini

nano /etc/php/7.0/fpm/php.ini

# At the end of the file set xdebug.remote_enable to true
xdebug.remote_enable=true

# Add your local host ip here
xdebug.remote_host=192.168.178.28

If you use php 5.6 you find the php.ini in the following directory:

/etc/php5/fpm/

How do i find my local host ip on mac?

To get your local host ip click on your wifi symbol top right --> Open Network Preferences

Local Host IP

Step 3: Restart php-fpm

pkill php && /etc/init.d/php-fpm restart

Step 4: Create Debugging Configuration

In our example we will explain how to configure Xdebug with PhpStorm.

The first step is to click in the top menu on Run --> Edit Configurations.

From there you create a new PHP Web Application Configuration:

PhpStorm PHP Web Application Configuration

When you create the "Server" make sure to use path mappings:

PhpStorm Server Configuration

Step 5: Start Debugging

You can now start debugging with Xdebug. PhStorm listen on Port 9000 and the docker container sends all data to the IDE.