Xdebug not installed on php 8.3 docker container

I’m using this Dockerfile

FROM php:8.3-apache

RUN pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug

RUN apt-get update && apt-get install -y \
    libfreetype6-dev \
    libjpeg62-turbo-dev \
    libpng-dev \
    libzip-dev \
    zip \
    && docker-php-ext-configure gd --with-freetype --with-jpeg \
    && docker-php-ext-install -j$(nproc) gd pdo pdo_mysql zip

RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
RUN echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

RUN a2enmod rewrite

EXPOSE 9003

WORKDIR /var/www/html

COPY apache-config.conf /etc/apache2/sites-available/000-default.conf

COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer

CMD ["apache2-foreground"]

when I check phpinfo() I see that xdebug is no t installed, the same Dockerfile with

FROM php:8.1-apache

RUN pecl install xdebug-3.1.1 && docker-php-ext-enable xdebug

works with no problems

I checked on xdebug web and xdebug 3.3.2 is compatible with php 8.3

The issue you are encountering might stem from compatibility or how Xdebug is installed in your Docker container. Here are a few potential steps to troubleshoot and fix the problem:

  1. Check Compatibility and Versions: Ensure that Xdebug 3.3.2 is fully compatible with PHP 8.3. Even though the website may say it’s compatible, there might be a need for adjustments in installation.
  2. Add More Logging: You can add more logging to check why Xdebug might not be installing properly:

bash

Copy code

RUN pecl install xdebug-3.3.2 && docker-php-ext-enable xdebug && php -v && php -m

This will help confirm if Xdebug is installed properly and whether it’s being recognized by PHP.
3. Rebuild the Docker Image: If there is any cache issue with Docker, try rebuilding your image without caching:

bash

Copy code

docker-compose build --no-cache

This forces Docker to install everything from scratch.
4. Manually Verify Installation: After running the Docker container, you can manually enter the container and check if Xdebug is installed:

bash

Copy code

docker exec -it <container_name> bash
pecl list
php -m | grep xdebug
  1. Update pecl Channel: Sometimes, the pecl repository itself might need an update:

bash

Copy code

RUN pecl channel-update pecl.php.net
  1. Try a Different Xdebug Version: If the above steps fail, try installing a different version of Xdebug. For example:

bash

Copy code

RUN pecl install xdebug-3.3.1
  1. Verify Configuration: Ensure that the Xdebug configuration is being correctly applied. You can check the config directory by running:

bash

Copy code

php --ini

Ensure that the docker-php-ext-xdebug.ini file is loaded.

By following these steps, you should be able to narrow down the problem and fix the Xdebug installation issue on PHP 8.3.