Docker Php Xdebug



  1. Docker Php Xdebug
  2. Docker Php Xdebug Cli

FROM php:7.3 WORKDIR /var/www # Install dependencies RUN apt-get update # Install extensions RUN docker-php-ext-install mbstring bcmath # XDEBUG RUN pecl install xdebug RUN docker-php-ext-enable xdebug # This needs in order to run xdebug from PhpStorm ENV PHPIDECONFIG 'serverName=DockerApp' ADD php.ini /usr/local/etc/php. Xdebug is an extension for debugging your PHP code. Magento Cloud Docker provides a separate container to handle Xdebug requests in the Docker environment. Use this container to enable Xdebug and debug PHP code in your Docker environment without affecting your.

XDebug 3 only started working out of the box with PhpStorm version 2020.3

Reference article - Configure Xdebug

The list of changes from XDebug 2 to 3 are available here for reference - Upgrade Guide

Docker php xdebug

Configuring PhpStorm

Go to PhpStorm -> Settings -> Languages & Frameworks -> PHP -> Servers

  1. Click '+'
  2. Name docker-cli (Same as serverName under PHP_IDE_CONFIG environment variable)
  3. Host _
  4. Default 80
  5. Debugger Xdebug
  6. Check the checkbox next to 'Use path mappings'
  7. Modify the absolute path on the server to /var/www/html

Running the CLI Command

Php

Docker Php Xdebug

  1. Add breakpoints file
  2. In PhpStorm click the icon to 'Start Listening for PHP Debug connections'
  3. Run in the docker file - docker-compose run php-container php test.php

Troubleshooting

Php

Docker Php Xdebug Cli

  1. Check firewall or selinux if on linux
  2. The configuration host.docker.internal only became available under Mac and Windows with Docker version 20.04