PHP error: "The zip extension and unzip command are both missing, skipping."

PhpComposer Php

Php Problem Overview


When I run a composer update I 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 source

What do I need to do to enable the zip and unzip commands so that composer can download dependencies?

Php Solutions


Solution 1 - Php

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 - Php

For servers with PHP 5.6

sudo apt-get install zip unzip php5.6-zip

Solution 3 - Php

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 - Php

For older Ubuntu distros i.e 16.04, 14.04, 12.04 etc

sudo apt-get install zip unzip php7.0-zip

Solution 5 - Php

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 6 - Php

I had PHP7.2 on a Ubuntu 16.04 server and it solved my problem:

sudo apt-get install zip unzip php-zip

Update

Tried this for Ubuntu 18.04 and worked as well.

Solution 7 - Php

I'm Using Ubuntu and with the following command worked

apt-get install --yes zip unzip

Solution 8 - Php

On docker with image php:7.2-apache I just needed zip and unzip. No need for php-zip :

apt-get install zip unzip

or Dockerfile

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "zip"]
RUN ["apt-get", "install", "-y", "unzip"]

Solution 9 - Php

If you are using Ubuntu and PHP 7.2, use this...

sudo apt-get update
sudo apt-get install zip unzip php7.2-zip

Solution 10 - Php

I got this error when I installed Laravel 5.5 on my digitalocean cloud server (Ubuntu 18.04 and PHP 7.2) and the following command fixed it.

> sudo apt install zip unzip php7.2-zip

Solution 11 - Php

Actually composer nowadays seems to work without the zip command line command, so installing php-zip should be enough --- BUT it would display a warning:

> 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. Installing 'unzip' may > remediate them.

See also https://stackoverflow.com/questions/52444600/is-there-a-problem-with-using-php-zip-composer-warns-about-it

Solution 12 - Php

PHP-ZIP needs some dependancies or library missing, depends on the image from Dockerfile you need to install them first

RUN set -eux \
   && apt-get update \
   && apt-get install -y libzip-dev zlib1g-dev \
   && docker-php-ext-install zip

Solution 13 - Php

Try this for PHP 7.4:

sudo apt-get install zip unzip php7.4-zip

And for PHP 8.0:

sudo apt-get install zip unzip php8.0-zip

Solution 14 - Php

The shortest command to fix it on Debian and Ubuntu (dependencies will be installed automatically):

sudo apt install php-zip

Solution 15 - Php

PHP 8.1

apt-get install --yes zip

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionb85411View Question on Stackoverflow
Solution 1 - PhpArrisarView Answer on Stackoverflow
Solution 2 - PhpOlawaleView Answer on Stackoverflow
Solution 3 - PhpDJ SipeView Answer on Stackoverflow
Solution 4 - PhpGoke ObasaView Answer on Stackoverflow
Solution 5 - PhpPeter BreulsView Answer on Stackoverflow
Solution 6 - PhpAqib AshefView Answer on Stackoverflow
Solution 7 - PhpOscar GallardoView Answer on Stackoverflow
Solution 8 - PhpArmel LarcierView Answer on Stackoverflow
Solution 9 - PhpaphoeView Answer on Stackoverflow
Solution 10 - PhpJoyalView Answer on Stackoverflow
Solution 11 - PhpAlexView Answer on Stackoverflow
Solution 12 - PhpPascal TovoheryView Answer on Stackoverflow
Solution 13 - PhpPejman KheyriView Answer on Stackoverflow
Solution 14 - PhpDevonDahonView Answer on Stackoverflow
Solution 15 - PhpfabpicoView Answer on Stackoverflow