Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MAMP PRO for Mac OSX - Installing PHP ZIP extension

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

thanks @kk-gjyang for the fix

@kk-gjyang

This comment has been minimized.

Copy link

@kk-gjyang kk-gjyang commented Mar 31, 2020

pecl install libzip didn't work for me, use brew install libzip and it works.

@yehgdotnet

This comment has been minimized.

Copy link
Owner Author

@yehgdotnet yehgdotnet commented Mar 31, 2020

pecl install libzip didn't work for me, use brew install libzip and it works.

Thanks for sharing.

pecl is insides MAMP directory - /Applications/MAMP/bin/php/php7.3.8/bin

@dniccum

This comment has been minimized.

Copy link

@dniccum dniccum commented Apr 3, 2020

This is the error that I got when trying to install libzip: No releases available for package "pecl.php.net/libzip"

@yehgdotnet

This comment has been minimized.

Copy link
Owner Author

@yehgdotnet yehgdotnet commented Apr 3, 2020

This is the error that I got when trying to install libzip: No releases available for package "pecl.php.net/libzip"

Thanks, Doug! I've corrected the original gist. Hope you rock with MAMP.

@stanionut

This comment has been minimized.

Copy link

@stanionut stanionut commented Apr 6, 2020

It worked for me! Thanks

@Ottergoose

This comment has been minimized.

Copy link

@Ottergoose Ottergoose commented Aug 7, 2020

Appreciate the info here; helped me clear a roadblock in another project. Thank you!

@zotopteam

This comment has been minimized.

Copy link

@zotopteam zotopteam commented Sep 11, 2020

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

PHP 7.4.2 (cli) (built: Feb 17 2020 12:56:02) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

In this case, PHP on the command line is PHP with Mamp Pro instead of PHP with MAC OS,Then:

vim ~/.profile

export PATH="/Applications/MAMP/bin/php/php7.4.2/bin:$PATH"
alias php='/Applications/MAMP/bin/php/php7.4.2/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/php7.4.2.ini"'
alias pear='/Applications/MAMP/bin/php/php7.4.2/bin/pear'
alias pecl='/Applications/MAMP/bin/php/php7.4.2/bin/pecl’

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

@LankyFrog

This comment has been minimized.

Copy link

@LankyFrog LankyFrog commented Dec 14, 2020

Make this version available on the command line

Thank you, this is the problem. Sometimes I feel I need to have a native setup over the MAMP

@riggerz29

This comment has been minimized.

Copy link

@riggerz29 riggerz29 commented Feb 10, 2021

Make this version available on the command line

Thanks you, this helped me out lots.

@amrikarisma

This comment has been minimized.

Copy link

@amrikarisma amrikarisma commented May 29, 2021

thank you, problem solved for me

@xicubed

This comment has been minimized.

Copy link

@xicubed xicubed commented Jun 10, 2021

It seemed like it wasn't running the right composer or php or something. After installing the zip.so I still had to run it by explicitly specifying paths for my php, ini and composer...

/Applications/MAMP/bin/php/php7.4.9/bin/php -c "/Library/Application Support/appsolute/MAMP PRO/conf/php7.4.9.ini" /Applications/MAMP/bin/php/composer update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment