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

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命令,以便编写器可以下载依赖项?


当前回答

在Debian和Ubuntu上修复它的最短命令(依赖项将自动安装):

sudo apt install php-zip

其他回答

PHP-ZIP需要一些依赖项或库缺失,这取决于你需要先安装Dockerfile中的镜像

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

对于使用PHP 5.6的服务器

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

对于较旧的Ubuntu发行版,如16.04,14.04,12.04等

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

PHP 8.1

apt-get install --yes 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问题,上面的内容是可爱的。