Add XDebug to unstable PHP version
My packages support the two latest minor versions of PHP. As the first alpha of PHP 8.3 was just released, I'm upgrading the packages to PHP 8.3 and dropping PHP 8.1 from them. This way I'm able to use readonly
for my classes.
I use XDebug in my packages for the development, but they obviously have no version that supports PHP 8.3 yet. But thanks to information I've got from the creator of XDebug (Derick Rethans), there is a way to use the main branch variant of XDebug.
As a reference, this is the Dockerfile I use for PHP 8.2:
FROM php:8.2-fpm-alpine3.16
RUN apk add --update \
autoconf \
g++ \
make \
linux-headers \
curl
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/
RUN pecl install xdebug-3.2.0 && docker-php-ext-enable xdebug
RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions uuid
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \
ln -s $(composer config --global home) /root/composer
ENV PATH=$PATH:/root/composer/vendor/bin COMPOSER_ALLOW_SUPERUSER=1
ADD php.ini /etc/php/conf.d/
ADD php.ini /etc/php/cli/conf.d/
ADD php.ini /usr/local/etc/php
ADD php-fpm.conf /etc/php/php-fpm.d/
WORKDIR /var/www/html
CMD ["php-fpm", "-F"]
What I need to replace is the command
RUN pecl install xdebug-3.2.0 && docker-php-ext-enable xdebug
with the following:
RUN apk add git
RUN apk add -U php8-dev --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing
RUN git clone https://github.com/xdebug/xdebug.git \
&& cd xdebug \
&& phpize \
&& ./configure \
&& make \
&& make install \
&& cd .. \
&& docker-php-ext-enable xdebug
As soon as the new version (which is officially supporting PHP 8.3) is released, you will be able to replace it again with this:
RUN pecl install xdebug-3.3.0 && docker-php-ext-enable xdebug