Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning
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 extensionsRUN 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 extensionsRUN 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:latestRUN apk update && apk upgradeRUN apk add php7 php7-zip composer
I built a PHP container on Docker using php:7.2-fpm-alpine
FROM php:7.2-fpm-alpineWORKDIR /var/wwwRUN apk add --no-cache zip libzip-devRUN docker-php-ext-configure zip --with-libzipRUN docker-php-ext-install zipRUN docker-php-ext-install pdo pdo_mysql
In case you are using 7.4 this worked for me:
FROM php:7.4-fpm-alpineRUN apk add --no-cache zip libzip-devRUN docker-php-ext-configure zipRUN docker-php-ext-install zipRUN docker-php-ext-install pdo pdo_mysql