Attention

You can now run different PHP versions per project: Release v3.0.0-beta-0.1

3.2.2.2. Docker on MacOS: Xdebug for PhpStorm

Note

Docker on MacOS requires you to create a host address alias on your loopback device.

Table of Contents

3.2.2.2.1. Prerequisites

Ensure you know how to customize php.ini values for the Devilbox and have a rough understanding about common Xdebug options.

Important

Ensure you have created an Host address alias on MacOS and 10.254.254.254 is aliased to your localhost.

3.2.2.2.2. Assumption

For the sake of this example, we will assume the following settings and file system paths:

Directory Path
Devilbox git directory /home/cytopia/repo/devilbox
HOST_PATH_HTTPD_DATADIR ./data/www
Resulting local project path /home/cytopia/repo/devilbox/data/www
Selected PHP version 5.6
Host address alias 10.254.254.254 (see prerequisites)

The Resulting local project path is the path where all projects are stored locally on your host operating system. No matter what this path is, the equivalent remote path (inside the Docker container) is always /shared/httpd.

Important

Remember this, when it comes to path mapping in your IDE/editor configuration.

3.2.2.2.3. Configuration

3.2.2.2.3.1. Configure PhpStorm

1. Ensure Xdebug port is set to 9000

../../../_images/phpstorm-settings.png

PHPStorm settings: Xdebug

2. Set path mapping

Create a new PHP server and set a path mapping. This tutorial assumes your local Devilbox projects to be in ./data/www of the Devilbox git directory:

../../../_images/phpstorm-path-mapping.png

PHPStorm settings: path mapping

Important

Recall the path settings from the Assumption section and adjust if your configuration differs!

3. Ensure DBGp proxy settings are configured

../../../_images/phpstorm-dbgp-proxy.png

PHPStorm settings: DBGp Proxy

3.2.2.2.3.2. Configure php.ini

Note

The following example show how to configure PHP Xdebug for PHP 5.6:

Create an xdebug.ini file (must end by .ini):

# Navigate to the Devilbox git directory
host> cd path/to/devilbox

# Navigate to PHP 5.6 ini configuration directory
host> cd cfg/php-ini-5.6/

# Create and open debug.ini file
host> vi xdebug.ini

Copy/paste all of the following lines into the above created xdebug.ini file:

xdebug.ini
; Defaults
xdebug.default_enable=1
xdebug.remote_enable=1
xdebug.remote_port=9000

; The MacOS way
xdebug.remote_connect_back=0
xdebug.remote_host=10.254.254.254

; idekey value is specific to PhpStorm
xdebug.idekey=PHPSTORM

; Optional: Set to true to always auto-start xdebug
xdebug.remote_autostart=false

Important

Ensure you have created a Host address alias on MacOS pointing to 10.254.254.254 as stated in the prerequisites section above!

Note

Host os and editor specific settings are highlighted in yellow and are worth googling to get a better understanding of the tools you use and to be more efficient at troubleshooting.

3.2.2.2.3.3. Restart the Devilbox

Restarting the Devilbox is important in order for it to read the new PHP settings. Note that the following example only starts up PHP, HTTPD and Bind.

# Navigate to the Devilbox git directory
host> cd path/to/devilbox

# Stop, remove stopped container and start
host> docker-compose stop
host> docker-compose rm
host> docker-compose up php httpd bind

See also

Stop and Restart (Why do docker-compose rm?)