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

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


当前回答

如果您使用的是像XAMPP这样的本地开发环境,只需找到php.ini文件(在我的例子中是C:\ XAMPP \php),打开它并从下面的行中删除分号。

;extension=zip

重新启动Apache web服务器,它将正常工作。

其他回答

安装7 zip从这个网站https://www.7-zip.org/download.html这个软件解压缩文件,为您解决了错误

对于Debian Jessie(这是Docker Hub上PHP映像的当前默认):

apt-get install --yes zip unzip php-pclzip

你可以省略——是的,但当你在Dockerfile中运行它时,它很有用。

适用于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"

对于使用PHP 5.6的服务器

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

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

sudo apt install php-zip