为 Mac 安装 ext-zip
install ext-zip for Mac
我正在尝试 运行 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].
当运行宁composer update
一夜之间,我犯了我一生的错误,让我的 Mac 自动更新 OS,所以我现在在 macOS Catalina 中。
我试过添加
"require": {
"ext-zip": "*",
}
我的composer.json..但它没有下载那个扩展。
将 Mac 更新到 Catalina 后,我遇到了同样的问题。这是对我有用的。
brew update
brew install php@7.3
brew link php@7.3
然后重新加载您的主机。
它将安装 php 7.3.10 和 zip 模块。您可以使用 php -v 检查版本,使用 php -m 检查模块。
我在 brew install php
期间遇到了 python 符号链接的问题。
/usr/local/Frameworks
不存在所以我必须创建它:
sudo mkdir /usr/local/Frameworks
cd /usr/local/
然后我不得不大吃一惊:
sudo chown -R myuser:admin Frameworks
我根据 /usr/local
中其余文件夹的权限设置。
那我可以运行brew link python
。
然后我又运行brew install php
又完成了。
php -v
现在给了我 php 7.3.10 ,我认为之前是 php 7.3.18。
以下命令修复了 macOS Catalina 上的问题
brew link php@7.3 --force
除了强制链接,您还可以解决 MacOS Catalina 中的问题
通过将 php 二进制路径添加到您的 bash 配置文件,例如:
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.3/sbinbin:$PATH"' >> ~/.bash_profile
如果 brew link 不适合您,请检查您安装的 php 版本:
ls /usr/local/opt/php*
在这里,您将看到这样的版本:
/usr/local/opt/php@7.3/bin:$PATH
应该给你这样的输出:
/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
现在您只需要 link 将其添加到您的 $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
注意:我使用的是 .zshrc,因为这是我的终端设置。如果你的是 bash,请相应地使用。
您可以通过 运行 检查哪个版本的 php 现在 linked 到您的 MacOS:
which php
这应该给你一个输出:
/usr/local/opt/php@7.3/bin/php
就是这样。现在,如果您尝试 composer update,它应该不会给您带来扩展问题。
来源(部分):https://medium.com/@jjdanek/installing-php-extensions-on-mac-after-homebrew-acfddd6be602
这对我有用
brew update
brew install php@7.3
brew link php@7.3
brew link php@7.3 --force
希望对您有所帮助
在我的例子中,我不得不简单地
brew link --overwrite php
2020 年 3 月 10 日,它适用于我:
brew install php
这是关于 PHP 的唯一一条有效的命令。
所以,我认为上一篇文章中显示的命令已被弃用。
2020-05-16 更新
正如@marc-alexander 所说,这是一种不好的做法。如果您不确定自己在做什么,则不应使用 --ignore-platform-reqs
选项。
我认为该选项会忽略平台要求并安装 特定版本 的软件包。但实际上它会忽略平台要求并安装 最高可用版本 的软件包。
因此,如果您需要缺少的 PHP 扩展,您应该安装(或启用)它
参考:ignore-platform-reqs installs dev-master instead of correct version
原创
如果你不需要ext-zip
(例如你只是想做一些快速修复),你可以使用--ignore-platform-reqs
选项忽略要求:
$ composer update --ignore-platform-reqs
我知道这个帖子有正确的答案,我用这种方法做那些:
brew link php@7.3
提示使用
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc
在终端中,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
执行which php
结果必须显示/usr/local/opt/php@7.3/bin/php
重试作曲家更新,如果显示 Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.2/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
请将 php.ini 限制更改为 memory_limit = -1
尝试搜索php.ini,在终端输入/usr/local/opt/php@7.3/bin/php --ini
,结果必须显示:Configuration File (php.ini)
Path: /usr/local/etc/php/7.3 Loaded Configuration File: /usr/local/etc/php/7.3/php.ini Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
nano /usr/local/etc/php/7.3/php.ini
,附加memory_limit =-1,保存
重启php
re-execution作曲家更新。
希望我的回答能帮到您。
正如其他用户已经提到的那样:此错误通常意味着您的 PATH 变量设置不正确,因此终端找不到某些 MAMP 二进制文件。
Shell 配置
我在 .zshrc
(或 .bashrc
)配置文件中使用以下代码为当前 PHP 版本设置正确的路径:
export PHP_VERSION=$(php -r 'echo PHP_VERSION;')
export PATH="/Applications/MAMP/Library/bin/:$PATH"
export PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH"
详情
export PHP_VERSION=$(php -r 'echo PHP_VERSION;')
此行从当前 PHP 解释器获取 PHP 版本。之后,您可以在任何 shell 脚本中访问 $PHP_VERSION
。
export PATH="/Applications/MAMP/Library/bin/:$PATH"
这是 MAMP 集成工作所需的标准路径
export PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH"
这是重要的部分,它将正确的 phpX.Y.Z
文件夹添加到路径列表中。这一行使用我们在上面第一行中获取的$PHP_VERSION
。
检查
将上述代码段添加到 .zshrc
(或 .bashrc
)后,您需要通过 运行 以下命令
加载更新的 shell 配置文件
source ~/.zshrc # or ~/.bashrc
最后,您可以快速检查一下 PATH 值是否正确:
echo -e ${PATH//:/\n}
# Output:
...
/Applications/MAMP/bin/php/php7.4.12/bin/ ← this line contains the PHP version
/Applications/MAMP/Library/bin/
...
我正在尝试 运行 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].
当运行宁composer update
一夜之间,我犯了我一生的错误,让我的 Mac 自动更新 OS,所以我现在在 macOS Catalina 中。
我试过添加
"require": {
"ext-zip": "*",
}
我的composer.json..但它没有下载那个扩展。
将 Mac 更新到 Catalina 后,我遇到了同样的问题。这是对我有用的。
brew update
brew install php@7.3
brew link php@7.3
然后重新加载您的主机。
它将安装 php 7.3.10 和 zip 模块。您可以使用 php -v 检查版本,使用 php -m 检查模块。
我在 brew install php
期间遇到了 python 符号链接的问题。
/usr/local/Frameworks
不存在所以我必须创建它:
sudo mkdir /usr/local/Frameworks
cd /usr/local/
然后我不得不大吃一惊:
sudo chown -R myuser:admin Frameworks
我根据 /usr/local
中其余文件夹的权限设置。
那我可以运行brew link python
。
然后我又运行brew install php
又完成了。
php -v
现在给了我 php 7.3.10 ,我认为之前是 php 7.3.18。
以下命令修复了 macOS Catalina 上的问题
brew link php@7.3 --force
除了强制链接,您还可以解决 MacOS Catalina 中的问题
通过将 php 二进制路径添加到您的 bash 配置文件,例如:
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.3/sbinbin:$PATH"' >> ~/.bash_profile
如果 brew link 不适合您,请检查您安装的 php 版本:
ls /usr/local/opt/php*
在这里,您将看到这样的版本:
/usr/local/opt/php@7.3/bin:$PATH
应该给你这样的输出:
/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
现在您只需要 link 将其添加到您的 $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
注意:我使用的是 .zshrc,因为这是我的终端设置。如果你的是 bash,请相应地使用。
您可以通过 运行 检查哪个版本的 php 现在 linked 到您的 MacOS:
which php
这应该给你一个输出:
/usr/local/opt/php@7.3/bin/php
就是这样。现在,如果您尝试 composer update,它应该不会给您带来扩展问题。
来源(部分):https://medium.com/@jjdanek/installing-php-extensions-on-mac-after-homebrew-acfddd6be602
这对我有用
brew update
brew install php@7.3
brew link php@7.3
brew link php@7.3 --force
希望对您有所帮助
在我的例子中,我不得不简单地
brew link --overwrite php
2020 年 3 月 10 日,它适用于我:
brew install php
这是关于 PHP 的唯一一条有效的命令。 所以,我认为上一篇文章中显示的命令已被弃用。
2020-05-16 更新
正如@marc-alexander 所说,这是一种不好的做法。如果您不确定自己在做什么,则不应使用 --ignore-platform-reqs
选项。
我认为该选项会忽略平台要求并安装 特定版本 的软件包。但实际上它会忽略平台要求并安装 最高可用版本 的软件包。
因此,如果您需要缺少的 PHP 扩展,您应该安装(或启用)它
参考:ignore-platform-reqs installs dev-master instead of correct version
原创
如果你不需要ext-zip
(例如你只是想做一些快速修复),你可以使用--ignore-platform-reqs
选项忽略要求:
$ composer update --ignore-platform-reqs
我知道这个帖子有正确的答案,我用这种方法做那些:
brew link php@7.3
提示使用
echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc
在终端中,
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
执行
which php
结果必须显示/usr/local/opt/php@7.3/bin/php
重试作曲家更新,如果显示
Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.2/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52
请将 php.ini 限制更改为memory_limit = -1
尝试搜索php.ini,在终端输入
/usr/local/opt/php@7.3/bin/php --ini
,结果必须显示:Configuration File (php.ini)Path: /usr/local/etc/php/7.3 Loaded Configuration File: /usr/local/etc/php/7.3/php.ini Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
nano /usr/local/etc/php/7.3/php.ini
,附加memory_limit =-1,保存重启php
re-execution作曲家更新。
希望我的回答能帮到您。
正如其他用户已经提到的那样:此错误通常意味着您的 PATH 变量设置不正确,因此终端找不到某些 MAMP 二进制文件。
Shell 配置
我在 .zshrc
(或 .bashrc
)配置文件中使用以下代码为当前 PHP 版本设置正确的路径:
export PHP_VERSION=$(php -r 'echo PHP_VERSION;')
export PATH="/Applications/MAMP/Library/bin/:$PATH"
export PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH"
详情
export PHP_VERSION=$(php -r 'echo PHP_VERSION;')
此行从当前 PHP 解释器获取 PHP 版本。之后,您可以在任何 shell 脚本中访问$PHP_VERSION
。export PATH="/Applications/MAMP/Library/bin/:$PATH"
这是 MAMP 集成工作所需的标准路径export PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH"
这是重要的部分,它将正确的phpX.Y.Z
文件夹添加到路径列表中。这一行使用我们在上面第一行中获取的$PHP_VERSION
。
检查
将上述代码段添加到 .zshrc
(或 .bashrc
)后,您需要通过 运行 以下命令
source ~/.zshrc # or ~/.bashrc
最后,您可以快速检查一下 PATH 值是否正确:
echo -e ${PATH//:/\n}
# Output:
...
/Applications/MAMP/bin/php/php7.4.12/bin/ ← this line contains the PHP version
/Applications/MAMP/Library/bin/
...