Reputation: 321
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:
The displayed error:
Cannot parse PHPUnit version output: Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED) PHPUnit 9.5.25 #StandWithUkraine
Because of this error, I can't run PHPUnit in coverage mode with PhpStorm.
The error comes from this line in my Dockerfile:
RUN docker-php-ext-enable xdebug
If I remove it, my PHP configuration doesn't have Xdebug:
PHP 8.1.10 (cli) (built: Sep 1 2022 21:39:29) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.10, Copyright (c) Zend Technologies
With this, from PHPStorm, I can launch my unit tests without errors but, I don't have access to the coverage of my unit tests.
If I remove RUN docker-php-ext-enable xdebug
from my Dockerfile, Xdebug is not activated and so I cannot with PHPStorm see the files covered by my tests.
When I try to run unit tests with coverage on PHPStorm:
Can you help me, please?
Upvotes: 1
Views: 1609
Reputation: 36784
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.
Upvotes: 3