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

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


当前回答

请先检查你的作曲状态

composer diagnose 

如果状态显示

zip: extension not found, unzip not available, 7-Zip not available

then

打开XAMPP服务器 >点击“PHP(PHP .ini)” 找到“zip” extension = zip将显示 删除分号并保存文件 重新启动XAMPP Apache

Now

composer create-project laravel/laravel <<project_name>>

or

laravel new <<project_name>>

其他回答

PHP 8.1

apt-get install --yes zip

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

Sudo apt安装解压php7.2-zip

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

;extension=zip

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

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

Sudo apt-get install zip解压php-zip

更新

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

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

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