PHP error: "The zip extension and unzip command are both missing, skipping."
Solution 1
Depending on your flavour of Linux and PHP version these may vary.
(sudo) yum install zip unzip php-zip
(sudo) apt install zip unzip php-zip
This is a very commonly asked question, you'll be able to find more useful info in the aether by searching <distro> php <version> zip extension.
Solution 2
For servers with PHP 5.6
sudo apt-get install zip unzip php5.6-zip
Solution 3
Not to belabor the point, but if you are working in a Dockerfile, you would solve this particular issue with Composer by installing the unzip utility. Below is an example using the official PHP image to install unzip and the zip PHP extension for good measure.
FROM php:7.4-apache
# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Install unzip utility and libs needed by zip PHP extension
RUN apt-get update && apt-get install -y \
zlib1g-dev \
libzip-dev \
unzip
RUN docker-php-ext-install zip
This is a helpful GitHub issue where the above is lovingly lifted from.
Solution 4
For Debian Jessie (which is the current default for the PHP image on Docker Hub):
apt-get install --yes zip unzip php-pclzip
You can omit the --yes, but it's useful when you're RUN-ing it in a Dockerfile.
Solution 5
For older Ubuntu distros i.e 16.04, 14.04, 12.04 etc
sudo apt-get install zip unzip php7.0-zip
Related videos on Youtube
b85411
Updated on July 08, 2022Comments
-
b85411 11 monthsWhen I run a
composer updateI get this error message:Loading composer repositories with package information Updating dependencies (including require-dev) Failed to download psr/log from dist: The zip extension and unzip command are both missing, skipping. The php.ini used by your command-line PHP is: /etc/php/7.0/cli/php.ini Now trying to download from sourceWhat do I need to do to enable the zip and unzip commands so that composer can download dependencies?
-
John Walker over 3 yearsWorkaround: Usecomposer update --prefer-sourceI had this issue when trying tocomposer updatephpspec.Failed to download symfony/polyfill-ctype from dist: The zip extension and unzip command are both missing, skipping.I am on a Mac and had problems making Homebrew work to install php extensions. So, my quick fix was to forcecomposernot to need to use zip by adding the --prefer-source option. This means it downloads the repo instead of a zipped package. Not a long term solution but handy to know.
-
-
Haring10 about 6 yearsYou are a life saver, my friend. -
lightup over 5 yearsincluding 16.04 -
Olaf Dietsche over 5 yearsFor Ubuntuapt-get install php-zipis sufficient -
thaerlabs over 5 yearsthanks for sharing Peter, saved me some time looking for the right version ofphp-zip:D -
elbowlobstercowstand almost 5 years@OlafDietsche How do you know/determine when to installphp[version]-packagevsphp-packagefor any given package? Would love to know as I usually just go with thephp[version]-packageversion, but perhaps that's not optimal… -
Olaf Dietsche almost 5 years@elbowlobstercowstandphp-<package>is the default version. These packages just depend on the most recent version. If you need some specific (usually older) version, you installphp<version>-<package>. -
umarbilal over 4 yearsWorked for me. Thanks -
Pathros over 4 yearsIt also works for# yum install zip unzip php7.2-zip(on CentOS 7) -
jgmjgm about 4 yearsPeople keep giving instructions to install php-zip as well as zip/unzip. It makes no sense that it needs both. -
naman1994 over 3 yearspeople using docker (nov '19) use : RUN apt-get install -y zlib1g-dev \ && docker-php-ext-install zip -
Thomas Praxl over 3 yearsI found that @naman1994's proposal is missinglibzip-devfor dockerfilesfrom php:7.3. So it should beRUN … apt-get install -yqq … zlib1g-dev libzip-dev && docker-php-ext-install zip -
Thomas Praxl over 3 yearsAlso, you really should install unzip. Otherwise composer will complain:As there is no 'unzip' command installed zip files are being unpacked using the PHP zip extension. This may cause invalid reports of corrupted archives. Besides, any UNIX permissions (e.g. executable) defined in the archives will be lost. Installing 'unzip' may remediate them.So it should beRUN … apt-get install -yqq … zlib1g-dev libzip-dev unzip && docker-php-ext-install zip -
Bobby Axe over 2 yearssudo apt-get install zip unzip php7.4-zip // according to your PHP version -
ortonomy about 2 yearsI enjoyed your prose in this answer. Thank you -
jpruiz114 almost 2 yearsIn my case, doing apt-get install -y zlib1g-dev libzip-dev unzip gets the error gone. -
Vladimir Vukanac over 1 yearIf warning comes from composer executed in php:7.4-cli with Dockerfile, by installing justzipwarning goes away.RUN apt-get update && apt-get install -y zip. It didn't request for unzip, libs nor docker-php-ext...