From Terminal
# install dependencies
brew install autoconf # required by pecl
brew install libzip
# install zip extenion in your selected MAMP PHP version
ls /Applications/MAMP/bin/php/
cd /Applications/MAMP/bin/php/php[Version]bin
pecl install zip
# edit php.ini in your selected MAMP PHP version
ls /Applications/MAMP/conf/p*
cd /Applications/MAMP/conf/php7.3.8/
echo "extension=zip" >> php.ini
When using Mamp Pro, if you are using composer and encounter the following error,It's possible that you didn't really lose PHP ZIP and you don't need to install it.
phpoffice/phpspreadsheet 1.14.1 requires ext-zip * -> the requested php extension zip is missing from your system.
You can try the following methods to check:
When switching between the PHP version of Mamp Pro, check the box on mamp pro
Make this version available on the command line
Exit and restart the terminal,input:
php -v
In this case, PHP on the command line is PHP with Mamp Pro instead of PHP with MAC OS,Then:
vim ~/.profile
The point is that the following line:
export PATH="/Applications/MAMP/bin/php/php7.4.2/bin:$PATH"
Not that Mamp Pro does not have zip, but that the PHP that composer use is not PHP for Mamp Pro,The reason for this problem is the USE of PHP in Composer, which means you need to set the MAC environment variable to make Composer use MAMP PHP
For more information, open the Composer file and see the following code as the first line of the file
#!/usr/bin/env php