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:
client
db
admin
php
api
cache-proxy
proxy
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.remote_port=9000 xdebug.remote_enable=1 xdebug.remote_connect_back=0 xdebug.idekey = "PHPSTORM" xdebug.remote_host = "10.254.254.254"
on your host machine run this on the command line:
$> sudo ifconfig lo0 alias 10.254.254.254
file: api/.env
PHP_IDE_CONFIG=serverName=docker
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:
- xdebug is enabled as a plugin
- environment variable: PHP_IDE_CONFIG, is indeed set… and without quotes.
- your absolute path on the server is correct
Hoped this helps others… as it wasn’t straight forward at all for me.
see: https://blog.philipphauer.de/debug-php-docker-container-idea-phpstorm/
todo for this post: fix links for dropbox images.
Leave a Reply