phpdockerphp-extensionlibzip

Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning


I have a Dockerfile with a build command like this:

#install some base extensions
RUN apt-get install -y \
        zlib1g-dev \
        zip \
  && docker-php-ext-install zip

I get this warning from build output:

WARNING: Use of bundled libzip is deprecated and will be removed.
configure: WARNING: Some features such as encryption and bzip2 are not available.
configure: WARNING: Use system library and --with-libzip is recommended.

What is the correct way to install the zip extension without these warnings?

My complete Dockerfile looks like:

FROM php:7.2-apache

RUN apt-get clean
RUN apt-get update

#install some basic tools
RUN apt-get install -y \
        git \
        tree \
        vim \
        wget \
        subversion

#install some base extensions
RUN apt-get install -y \
        zlib1g-dev \
        zip \
  && docker-php-ext-install zip

#setup composer
RUN curl -sS https://getcomposer.org/installer | php \
        && mv composer.phar /usr/local/bin/ \
        && ln -s /usr/local/bin/composer.phar /usr/local/bin/composer


WORKDIR /var/www/

Solution

  • It looks like PHP no longer bundles libzip. You need to install it. You install zlib1g-dev, but instead install libzip-dev. This installs zlib1g-dev as a dependency and allows the configure script to detect that libzip is installed.

    For PHP < 7.3, you then need to

    docker-php-ext-configure zip --with-libzip
    

    before performing the installation with

    docker-php-ext-install zip
    

    as the last warning indicates.

    In short: change the relevant part of your Dockerfile to

    For PHP < 7.3

    #install some base extensions
    RUN apt-get install -y \
            libzip-dev \
            zip \
      && docker-php-ext-configure zip --with-libzip \
      && docker-php-ext-install zip
    

    For PHP >= 7.3

    #install some base extensions
    RUN apt-get install -y \
            libzip-dev \
            zip \
      && docker-php-ext-install zip
    

    I have verified that this builds as expected.

     


     

    In case you are not using the Docker PHP base image, things may be much easier. For example, for Alpine the following Dockerfile will get you PHP 7 with the zip extension installed.

    FROM alpine:latest
    
    RUN apk update && apk upgrade
    RUN apk add php7 php7-zip composer