当我运行一个作曲器更新时,我得到这个错误消息:

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

我需要做什么才能启用zip和unzip命令,以便编写器可以下载依赖项?


当前回答

如果你使用Ubuntu和PHP 7.2,使用这个…

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

其他回答

我不想赘述这一点,但如果您在Dockerfile中工作,您可以通过安装unzip实用程序来解决Composer的这个特殊问题。下面是一个使用官方PHP映像安装unzip和zip PHP扩展的示例。

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

这是一个很有用的GitHub问题,上面的内容是可爱的。

我正在使用Ubuntu,并使用以下命令工作

Apt-get install——yes zip unzip

在docker上使用image php:7.2-apache,我只需要zip和unzip。不需要php-zip:

安装zip解压

或 Dockerfile

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

当我在digitalocean云服务器(Ubuntu 18.04和PHP 7.2)上安装Laravel 5.5时,我得到了这个错误,下面的命令修复了它。

Sudo apt安装解压php7.2-zip

适用于PHP8.2 (Windows)

如上所述:https://www.php.net/manual/en/zip.installation.php#zip.installation.new.windows

从PHP 8.2.0开始,php_zip.dll DLL必须在PHP .ini中启用。以前,这个扩展是内置的。

您需要在php.ini中手动启用这个扩展,添加extension=php_zip.dll

对于已安装扩展的列表,您可以运行:

php -m

或者如果你安装了grep,会更容易:

php -m | grep "zip"