Mac Docker PHP Xdebug and Api-platform and PHPStorm.

Having trying to debug without xdebug felt like my hands were being tied behind my back.
Took a while, but my friend Bart was able to help me get this up and running, after lots of trouble shooting.
The way it seems, api-platform sets docker up in distinct containers:

Wanting to debug in xdebug, on a mac, inside a docker container wasn’t as straight forward as I would have thought it could be.
Docker/alpine is running nginx. Nginx proxies the calls for php-fpm.
The meat and potatoes of getting this setup:
file: api/Dockerfile

	pecl install \
		xdebug-${XDEBUG_VERSION} \
	; \
	docker-php-ext-enable \
		apcu \
		opcache \
		xdebug \
	; \

file: api/docker/php/php.ini

xdebug.idekey = "PHPSTORM"
xdebug.remote_host = ""

on your host machine run this on the command line:

$> sudo ifconfig lo0 alias

file: api/.env


Run/Debug Configuration:

That should do it… change PHPSTORM, to your ide key… but PHPSTORM is pretty standard for PhpStorm.
Remember to rebuild your container… as sometimes (why I don’t know) changes don’t take effect until it’s rebuilt.
If you’re having troubles, look at “phpinfo();” or “$> php -v”. Check:

  1. xdebug is enabled as a plugin
  2. environment variable: PHP_IDE_CONFIG, is indeed set… and without quotes.
  3. your absolute path on the server is correct

Hoped this helps others… as it wasn’t straight forward at all for me.
todo for this post: fix links for dropbox images.

Leave a Reply

Your email address will not be published. Required fields are marked *