php 为 Mac 安装 ext-zip
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58290566/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
install ext-zip for Mac
提问by Abdul
I am trying to run composer update
and I get the following errors:
我正在尝试运行composer update
,但出现以下错误:
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].
when running composer update
跑步时 composer update
Overnight I have made the mistake of my life and allowed my Mac to automatically update the OS, so I am in macOS Catalina now.
一夜之间我犯了我一生的错误,让我的 Mac 自动更新操作系统,所以我现在在 macOS Catalina。
I have tried adding
我试过添加
"require": {
"ext-zip": "*",
}
to my composer.json..but its not downloading that extension.
到我的 composer.json .. 但它没有下载该扩展。
回答by Aldranor
I had the same problem after updating my Mac to Catalina. Here is what worked for me.
将 Mac 更新为 Catalina 后,我遇到了同样的问题。这对我有用。
brew update
brew install [email protected]
brew link [email protected]
Then reload your console.
然后重新加载您的控制台。
It will install php 7.3.10 with zip module. You can use php -v to check for the version, and php -m for the modules.
它将安装带有 zip 模块的 php 7.3.10。您可以使用 php -v 检查版本,使用 php -m 检查模块。
回答by Hamza Waleed
Following command fixed the issue on macOS Catalina
以下命令修复了 macOS Catalina 上的问题
brew link [email protected] --force
回答by SAVE.US_222
If brew link is not working for you, check your php version installed by:
如果 brew 链接对您不起作用,请检查您安装的 php 版本:
ls /usr/local/opt/php*
Here, you will see a version as such:
在这里,您将看到一个版本:
/usr/local/opt/[email protected]/bin:$PATH
Should give you an output like:
应该给你一个输出,如:
/usr/local/opt/[email protected]:
INSTALL_RECEIPT.json include
LICENSE lib
NEWS pecl
README.md sbin
bin share
[email protected]
Now you just need to link that to your $PATH which can be done as:
现在您只需要将其链接到您的 $PATH 即可,如下所示:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Note: I am using .zshrc because that is my terminal setup. If yours is bash, use accordingly.
注意:我使用 .zshrc 因为这是我的终端设置。如果您使用的是 bash,请相应地使用。
You can check which version of php is now linked to your MacOS by running:
您可以通过运行以下命令来检查哪个版本的 php 现在链接到您的 MacOS:
which php
This should give you an output of:
这应该给你一个输出:
/usr/local/opt/[email protected]/bin/php
That's it. Now if you try composer update, it should not give you the extension issue.
就是这样。现在,如果您尝试 composer update,它不应该给您扩展问题。
Source (part of it): https://medium.com/@jjdanek/installing-php-extensions-on-mac-after-homebrew-acfddd6be602
来源(部分):https: //medium.com/@jjdanek/installing-php-extensions-on-mac-after-homebrew-acfddd6be602
回答by InfiniteRoads
On 10 March 2020, It works for me:
2020 年 3 月 10 日,它对我有用:
brew install php
It is the only one command about PHP which work. So, I think that the commands shown in the last posts are deprecated.
它是关于 PHP 的唯一一个有效的命令。所以,我认为上一篇文章中显示的命令已被弃用。
回答by tommyskott
I had problems with python symlink during the brew install php
.
在brew install php
.
/usr/local/Frameworks
didn't exist so I had to create it:
sudo mkdir /usr/local/Frameworks
/usr/local/Frameworks
不存在所以我必须创建它:
sudo mkdir /usr/local/Frameworks
cd /usr/local/
cd /usr/local/
Then I had to chown it:
sudo chown -R myuser:admin Frameworks
然后我不得不 chown 它:
sudo chown -R myuser:admin Frameworks
I based the permission settings on the rest of the folders in /usr/local
.
我的权限设置基于/usr/local
.
Then I could run brew link python
.
Then I ran brew install php
again and it completed.
然后我就可以跑了brew link python
。然后我brew install php
再次运行,它完成了。
php -v
now gives me php 7.3.10 , before it was php 7.3.18 I think.
php -v
现在给了我 php 7.3.10 ,我想之前是 php 7.3.18 。
回答by MDeuerlein
Instead of force linking you can also fix the problem in MacOS Catalina
除了强制链接,您还可以解决 MacOS Catalina 中的问题
by adding the php binary path to your bash profile e.g.:
通过将 php 二进制路径添加到您的 bash 配置文件中,例如:
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbinbin:$PATH"' >> ~/.bash_profile
回答by bschen
2020-05-16 updated
2020-05-16 更新
Like @marc-alexander said, this is a bad practice. You should not use --ignore-platform-reqs
option if you do not sure what you are doing.
就像@marc-alexander 所说的那样,这是一种不好的做法。--ignore-platform-reqs
如果您不确定自己在做什么,则不应使用option。
I thought the option would ignore the platform requirements and install the specific versionof the packages. But in fact it will ignore the platform requirements and install the highest available versionof the packages.
我认为该选项会忽略平台要求并安装特定版本的软件包。但实际上它会忽略平台要求并安装最高可用版本的软件包。
So if you need the missing PHP extension, you should just install (or enable) it
所以如果你需要缺少的 PHP 扩展,你应该安装(或启用)它
Reference: ignore-platform-reqs installs dev-master instead of correct version
参考:ignore-platform-reqs 安装 dev-master 而不是正确的版本
Original
原来的
If you do not need ext-zip
(e.g. You just want to do some quick fix), you can use --ignore-platform-reqs
option to ignore the requirements:
如果您不需要ext-zip
(例如,您只想做一些快速修复),您可以使用--ignore-platform-reqs
选项忽略要求:
$ composer update --ignore-platform-reqs
回答by Habib Mammadov
This worked for me
这对我有用
brew update
brew install [email protected]
brew link [email protected]
brew link [email protected] --force
brew update
brew install [email protected]
brew link [email protected]
brew link [email protected] --force
Hope it helps
希望能帮助到你
回答by Jo?o Felipe Marques Ribeiro
In my case I had to simply
就我而言,我不得不简单地
brew link --overwrite php