如何在macOS High Sierra上安装PHP GMP?

时间:2018-06-29 08:33:18

标签: php composer-php homebrew macos-high-sierra

我正在尝试为PHP安装并启用GMP扩展。

Mac OS High Sierra 10.13.5
PHP Version: 7.1.16
Composer version: 1.6.5
Homebrew version: 1.6.9

运行composer install时出现此错误。

Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested PHP extension ext-gmp * is missing from your system. Install or enable PHP's gmp extension.

composer.json依赖于"ext-gmp": "*"。我尝试了以下操作:

  1. brew install homebrew/php/php70-gmp
  2. brew install gmp
  3. brew install homebrew/homebrew-core/php70-gmp
  4. 已更改php.ini以启用extension=php_gmp.dll

在Composer安装上仍然出现相同的错误。有人可以帮我吗?

2 个答案:

答案 0 :(得分:0)

重新开始。安装PHP 7

brew install php@7.1

将php路径添加到~/.bash_profile~/.zshrc

export PATH="/usr/local/opt/php@7.1/bin:$PATH"

然后源文件,启动php并检查gmp是否已加载

brew services start php@7.1
source ~/.zshrc
php -info | grep "GMP"

再试一次

答案 1 :(得分:0)

我能够按照以下指南进行修复-https://getgrav.org/blog/macos-sierra-apache-multiple-php-versions

它删除了已经安装的Apache和PHP。