docker – Fatal Error: composer.lock was created for PHP version 7.4.3 or higher but the current PHP version is 7.3.15-ThrowExceptions

Exception or error:

I’m have been battling this problem for ages. I have a docker setup which I have slightly modified this: https://github.com/eko/docker-symfony in attempt to get PHP 7.4 working however I always have the error:

Fatal Error: composer.lock was created for PHP version 7.4.3 or higher but the current PHP version is 7.3.15

My PHP version inside the container is 7.4.3 and my OS PHP version is also 7.4.3. Inside my composer.json I’ve tried changing the PHP version and adding platform config like so:

"platform": {
"php": "7.4.3"
}

Finally I have tried literally every suggestion from this post, none of which worked: Fatal Error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.3.11

Any help would be great, here is my Dockerfile:

FROM php:7.4-fpm-alpine

LABEL maintainer="Vincent Composieux <vincent.composieux@gmail.com>"

RUN apk add --update --no-cache \
    coreutils \
    php7-fpm \
    php7-apcu \
    php7-ctype \
    php7-curl \
    php7-dom \
    php7-gd \
    php7-iconv \
    php7-imagick \
    php7-json \
    php7-intl \
    php7-mcrypt \
    php7-fileinfo\
    php7-mbstring \
    php7-opcache \
    php7-openssl \
    php7-pdo \
    php7-pdo_mysql \
    php7-mysqli \
    php7-xml \
    php7-zlib \
    php7-phar \
    php7-tokenizer \
    php7-session \
    php7-simplexml \
    php7-xdebug \
    php7-zip \
    php7-xmlwriter \
    make \
    curl

#RUN ln -s /usr/bin/php7 /usr/bin/php

RUN echo "$(curl -sS https://composer.github.io/installer.sig) -" > composer-setup.php.sig \
        && curl -sS https://getcomposer.org/installer | tee composer-setup.php | sha384sum -c composer-setup.php.sig \
        && php composer-setup.php && rm composer-setup.php* \
        && chmod +x composer.phar && mv composer.phar /usr/bin/composer

COPY symfony.ini /etc/php7/conf.d/
COPY symfony.ini /etc/php7/cli/conf.d/
COPY xdebug.ini  /etc/php7/conf.d/

COPY symfony.pool.conf /etc/php7/php-fpm.d/

CMD ["php-fpm7", "-F", "-R"]

WORKDIR /var/www/symfony
EXPOSE 9001

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *