为Mac安装ext-zip

Abd*_*dul 19 macos laravel composer-php macos-catalina

我正在尝试运行作曲家更新,出现以下错误

Problem 1
    - The requested PHP extension ext-zip * is missing from your system. Install or enable PHP's zip extension.
  Problem 2
    - maatwebsite/excel 3.1.10 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.11 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.12 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.13 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.14 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.15 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.16 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.17 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.7 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.8 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.9 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.x-dev requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.2.x-dev requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.0 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.1 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.2 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.3 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.4 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.5 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.6 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - phpoffice/phpspreadsheet 1.9.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.2 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.7.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.6.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.2 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.4.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.4.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - Installation request for maatwebsite/excel ^3.1.0 -> satisfiable by maatwebsite/excel[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.14, 3.1.15, 3.1.16, 3.1.17, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.1.x-dev, 3.2.x-dev].
Run Code Online (Sandbox Code Playgroud)

when running作曲家更新`

一夜之间,我犯了我一生的错误,并允许我的Mac自动更新OS。所以我现在在macOS Catalina中。

我尝试添加

   "require": {
  "ext-zip": "*",}
Run Code Online (Sandbox Code Playgroud)

到我的composer.json ..,但没有下载该扩展名。

我现在如何运行作曲家更新,将对您有所帮助。

小智 51

将Mac更新到Catalina之后,我遇到了同样的问题。这对我有用。

brew update
brew install php@7.3
brew link php@7.3
Run Code Online (Sandbox Code Playgroud)

然后重新加载控制台。

它将安装带有zip模块的php 7.3.10。您可以使用php -v检查版本,并使用php -m查看模块。

  • 如果您看到此警告“php@7.3 is keg-only and must be linked with --force”,请使用“brew link --force php@7.3” (14认同)
  • 这有效,但只有在我添加之后: `export PATH="/usr/local/opt/php@7.3/bin:$PATH"` `export PATH="/usr/local/opt/php@7.3/sbin :$PATH"` 到我的 .zshrc (11认同)
  • 终于修好了!运行“ brew doctor”表示该文件夹不存在且不可写,并为您提供了运行命令。运行这些命令,再次运行link命令,重新加载控制台,一切恢复正常:) (6认同)
  • “然后重新加载你的控制台。”非常重要,我错过了关闭和打开终端的机会,并挣扎了几个小时。 (6认同)
  • @Aldranor 感觉这几乎可行,运行brew install 听起来是一个不错的计划。但是,现在出现“错误:无法符号链接 sbin/php-fpm”“/usr/local/sbin 不可写。”...brew 也不会运行 sudo...有什么想法吗? (2认同)

Ham*_*eed 37

以下命令修复了 macOS Catalina 上的问题

brew link php@7.3 --force
Run Code Online (Sandbox Code Playgroud)

  • 这是唯一对我有用的东西 - 谢谢! (2认同)

小智 18

2020 年 3 月 10 日,它对我有用:

brew install php  
Run Code Online (Sandbox Code Playgroud)

这是关于 PHP 的唯一一个有效的命令。所以,我认为上一篇文章中显示的命令已被弃用。


小智 16

如果 brew 链接对您不起作用,请检查您安装的 php 版本:

ls /usr/local/opt/php*
Run Code Online (Sandbox Code Playgroud)

在这里,您将看到一个版本:

/usr/local/opt/php@7.3/bin:$PATH
Run Code Online (Sandbox Code Playgroud)

应该给你一个输出,如:

/usr/local/opt/php@7.3:
INSTALL_RECEIPT.json        include
LICENSE                     lib
NEWS                        pecl
README.md                   sbin
bin                         share
homebrew.mxcl.php@7.3.plist
Run Code Online (Sandbox Code Playgroud)

现在您只需要将其链接到您的 $PATH 即可,如下所示:

echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Run Code Online (Sandbox Code Playgroud)

注意:我使用 .zshrc 因为这是我的终端设置。如果您使用的是 bash,请相应地使用。

您可以通过运行以下命令来检查哪个版本的 php 现在链接到您的 MacOS:

which php
Run Code Online (Sandbox Code Playgroud)

这应该给你一个输出:

/usr/local/opt/php@7.3/bin/php
Run Code Online (Sandbox Code Playgroud)

就是这样。现在,如果您尝试 composer update,它不应该给您扩展问题。

来源(部分):https : //medium.com/@jjdanek/installing-php-extensions-on-mac-after-homebrew-acfddd6be602


bsc*_*hen 15

2020-05-16 更新

就像@marc-alexander 所说的那样,这是一种不好的做法。--ignore-platform-reqs如果您不确定自己在做什么,则不应使用option。

我认为该选项会忽略平台要求并安装特定版本的软件包。但实际上它会忽略平台要求并安装最高可用版本的软件包。

所以如果你需要缺少的 PHP 扩展,你应该安装(或启用)它

参考:ignore-platform-reqs 安装 dev-master 而不是正确的版本

原来的

如果您不需要ext-zip(例如,您只想做一些快速修复),您可以使用--ignore-platform-reqs选项忽略要求:

$ composer update --ignore-platform-reqs
Run Code Online (Sandbox Code Playgroud)

  • 不好的做法。那么作曲家可能无法正确安装所有内容/跳过一些内容。 (2认同)

小智 6

这对我有用

brew update brew install php@7.3 brew link php@7.3 brew link php@7.3 --force

希望能帮助到你