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

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

其他回答

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

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

对于使用PHP 5.6的服务器

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

我在Ubuntu 16.04服务器上安装了PHP7.2,它解决了我的问题:

Sudo apt-get install zip解压php-zip

更新

在Ubuntu 18.04上尝试了这个方法,效果也不错。

PHP 8.1

apt-get install --yes zip

后运行

apt install php-zip

再跑一遍

composer require ...

我得到了下一个警告和建议

由于没有“unzip”或“7z”命令,安装的zip文件正在使用PHP zip扩展名进行解压缩。

这可能导致已损坏档案的无效报告。此外,在存档中定义的任何UNIX权限(例如可执行文件)都将丢失。

安装'unzip'或'7z'(21.01+)可以修复它们。

由于没有“unzip”或“7z”命令,安装的zip文件正在使用PHP zip扩展名进行解压缩。

这可能导致已损坏档案的无效报告。此外,在存档中定义的任何UNIX权限(例如可执行文件)都将丢失。

安装'unzip'或'7z'(21.01+)可以修复它们。

所以我建议先安装unzip。

apt install unzip