Docker Compose Php Xdebug



Issue

  1. Docker Php Fpm Xdebug
  2. Phpstorm Xdebug Docker Cli
  3. Phpstorm Docker Xdebug Not Working
  • A way to around inconsistent xdebug.remotehost behavior is to write a wrapper script that uses sed to replace the IP address in the docker-compose.yml file and then call docker-compose up -d. If you’re lucky enough to be using a Mac, you can simply add the following line to your xdebug.ini file instead of worrying about any environment.
  • Before Docker, Xdebug was relatively straightforward to configure on a platform, in that it was a new set of the php.ini parameters – you’d either just edit the existing php.ini, or load in a custom ini or override. Now we’re running PHP and fpm in a container, so we need to inject the configuration in with docker-compose.
  • Create a Dockerfile with xdebug installation for the development, dont use this for production, it will slow down your performance. Build your-wordpress image from that Dockerfile. You might need to create the xdebug.ini file with your remote host details, i'm using phpstrom this is what my xdebug.ini looks like.

XDebug can be difficult to configure with Docker due to the requirement ofremote host IP (remote_host option) after installing XDebug and callingecho 'nxdebug.remote_enable=1' >> /usr/local/etc/php/conf.d/xdebug.iniin your PHP image. So far I’ve encountered manual .env variable setups.But it’s possible to obtain it automatically.

Service 'php' failed to build: The command '/bin/sh -c pecl install xdebug' returned a non-zero code: 1 I have tried on both git cloned project and downloaded project from github. I am new to docker. Having any ARG or ENV setting in a Dockerfile evaluates only if there is no Docker Compose entry for environment or envfile. Specifics for NodeJS containers. If you have a package.json entry for script:start like NODEENV=test node server.js, then this overrules any setting in your docker-compose.yml file. Configure Compose using environment variables. Several environment variables are.

How would you do that?

You can use this Bash script to find the IP address more or less reliably onmost commonly used systems (Linux, Windows, Mac OS):

It reads the IP address based on $OSTYPE. Mac and Windows Docker versions providein-built definitions in their latest versions. Place the script in the samefolder as docker-compose.yml and run it with regular Docker Compose parameter(s).

Then in docker-compose.yml file you can add the following to your PHP service:

PHP_IDE_CONFIG environment variable is optional and requiresAPP_XDEBUG_SERVER_NAME=server.name in your .env file, which allowseasier setup in PHPStorm.

As you might have noticed in the script, you can still set the IP manually in .envif it’s not detected automatically.

Docker Php Fpm Xdebug

Issue

XDebug can be difficult to configure with Docker due to the requirement ofremote host IP (remote_host option) after installing XDebug and callingecho 'nxdebug.remote_enable=1' >> /usr/local/etc/php/conf.d/xdebug.iniin your PHP image. So far I’ve encountered manual .env variable setups.But it’s possible to obtain it automatically.

How would you do that?

You can use this Bash script to find the IP address more or less reliably onmost commonly used systems (Linux, Windows, Mac OS):

Phpstorm Xdebug Docker Cli

It reads the IP address based on $OSTYPE. Mac and Windows Docker versions providein-built definitions in their latest versions. Place the script in the samefolder as docker-compose.yml and run it with regular Docker Compose parameter(s).

Docker

Then in docker-compose.yml file you can add the following to your PHP service:

PHP_IDE_CONFIG environment variable is optional and requiresAPP_XDEBUG_SERVER_NAME=server.name in your .env file, which allowseasier setup in PHPStorm.

Phpstorm Docker Xdebug Not Working

As you might have noticed in the script, you can still set the IP manually in .envif it’s not detected automatically.