How to install PHP GMP on macOS High Sierra?

akshaykumar6 picture akshaykumar6 · Jun 29, 2018 · Viewed 8.3k times · Source

I am trying to install and enable GMP extension for PHP.

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

I am getting this error when I run 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.

The composer.json has dependency on "ext-gmp": "*" . I have tried following things:

  1. brew install homebrew/php/php70-gmp
  2. brew install gmp
  3. brew install homebrew/homebrew-core/php70-gmp
  4. Changed in php.ini to enable extension=php_gmp.dll

I'm still getting the same error on composer install. Can anyone please help me with this?

Answer

Umair Iftikhar picture Umair Iftikhar · Jun 29, 2018

Start Again. Install PHP 7

brew install [email protected]

add php path to ~/.bash_profile or ~/.zshrc :

export PATH="/usr/local/opt/[email protected]/bin:$PATH"

then source file, start php and check gmp has been loaded

brew services start [email protected]
source ~/.zshrc
php -info | grep "GMP"

Try Again