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

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


当前回答

对于使用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

根据您对Linux和PHP版本的喜好,这些可能会有所不同。

(sudo) yum install zip unzip php-zip
(sudo) apt install zip unzip php-zip

这是一个非常常见的问题,你可以通过搜索<distro> php <version> zip扩展名来找到更多有用的信息。

请先检查你的作曲状态

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>>

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

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

Apt-get install——yes zip unzip