Search for the PHP version
brew search gmp
homebrew/php/php53-gmp
homebrew/php/php54-gmp
homebrew/php/php55-gmp
homebrew/php/php56-gmp
homebrew/php/php70-gmp
homebrew/php/php71-gmp
brew install homebrew/php/php71-gmp
Find the GMP config file
ls /usr/local/etc/php/7.1/conf.d
cat /usr/local/etc/php/7.1/conf.d/ext-gmp.ini
[gmp]
extension="/usr/local/opt/php71-gmp/gmp.so"
Edit php.ini
nano /Applications/MAMP/bin/php/php7.1.1/conf/php.ini
[gmp]
extension="/usr/local/opt/php71-gmp/gmp.so"
Restart MAMP!
Add the PATH variabele to your profile:
nano ~/.bash_profile
source ~/.profile
export MAMP_PHP=/Applications/MAMP/bin/php/php7.1.1/bin
export PATH="$MAMP_PHP:$PATH"
alias php='/Applications/MAMP/bin/php/php7.1.1/bin/php'
Test
php -m | grep gmp