Home > Back-end >  Docker Image PHP 8.1.10 with Xdebug doesn't work with PhpStorm
Docker Image PHP 8.1.10 with Xdebug doesn't work with PhpStorm

Time:09-27

I have a problem with Xdebug, this is my Docker configuration:

Dockerfile:

FROM php:8.1.10-fpm-alpine
RUN apk update
RUN apk add php81-dev gcc make g   zlib-dev icu-dev bash git openssl yaml-dev

RUN pecl channel-update pecl.php.net

# For YAML
RUN apk add --update --no-cache \
          yaml && \
      # Build dependancy for YAML \
      apk add --update --no-cache --virtual .yaml-build \
          yaml-dev && \
      pecl install yaml && \
      docker-php-ext-enable yaml; \
      apk del .yaml-build

# For Xdebug
RUN pecl install xdebug
RUN docker-php-ext-enable xdebug
RUN echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

# For code coverage
RUN echo "memory_limit=-1" >> /usr/local/etc/php/conf.d/docker-php-memory-limit.ini

COPY --from=composer /usr/bin/composer /usr/bin/composer

SHELL ["/bin/bash", "-c"]

WORKDIR /var/www/html

docker-compose.yml:

version: '3'

services:
  php:
    build:
      context: ./
      dockerfile: Dockerfile
    volumes:
      - "./:/var/www/html"
      - "~/.composer:/root/.composer"

When I check the PHP information of my Docker image, everything seems correct:

PHP 8.1.10 (cli) (built: Sep  1 2022 21:43:31) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
    with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans

In PhpStorm, I setup correctly my remote PHP Interpreter with Docker Compose option.

The problem is here:

enter image description here

The displayed error:

Cannot parse PHPUnit version output: Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at enter image description here

Can you help me, please?

CodePudding user response:

If I remove it, Xdebug is not activated and so I cannot with PHPStorm see the files covered by my tests.

That's not right, if you want to have both coverage and the step debugger in with Xdebug 3, you need to change:

RUN echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

To:

RUN echo "xdebug.mode=coverage,debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

And remove the xdebug.remote_enable setting from wherever you set it.

  • Related