install ext-zip for Mac

PhpMacosComposer PhpCommand Line-InterfaceHomebrew

Php Problem Overview


I am trying to run composer update and I get the following errors:

Problem 1
    - The requested PHP extension ext-zip * is missing from your system. Install or enable PHP's zip extension.
  Problem 2
    - maatwebsite/excel 3.1.10 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.11 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.12 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.13 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.14 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.15 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.16 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.17 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.7 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.8 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.9 requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.x-dev requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.2.x-dev requires phpoffice/phpspreadsheet ^1.6 -> satisfiable by phpoffice/phpspreadsheet[1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.0 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.1 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.2 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.3 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.4 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.5 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - maatwebsite/excel 3.1.6 requires phpoffice/phpspreadsheet ^1.4 -> satisfiable by phpoffice/phpspreadsheet[1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.8.0, 1.8.1, 1.8.2, 1.9.0].
    - phpoffice/phpspreadsheet 1.9.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.2 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.8.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.7.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.6.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.2 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.5.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.4.1 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - phpoffice/phpspreadsheet 1.4.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
    - Installation request for maatwebsite/excel ^3.1.0 -> satisfiable by maatwebsite/excel[3.1.0, 3.1.1, 3.1.10, 3.1.11, 3.1.12, 3.1.13, 3.1.14, 3.1.15, 3.1.16, 3.1.17, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.8, 3.1.9, 3.1.x-dev, 3.2.x-dev].

when running composer update

Overnight I have made the mistake of my life and allowed my Mac to automatically update the OS, so I am in macOS Catalina now.

I have tried adding

 "require": {
    "ext-zip": "*",
 }

to my composer.json..but its not downloading that extension.

Php Solutions


Solution 1 - Php

I had the same problem after updating my Mac to Catalina. Here is what worked for me.

brew update
brew install php@7.3
brew link php@7.3

Then reload your console.

It will install php 7.3.10 with zip module. You can use php -v to check for the version, and php -m for the modules.

Solution 2 - Php

Following command fixed the issue on macOS Catalina

brew link php@7.3 --force

Solution 3 - Php

On 10 March 2020, It works for me:

brew install php  

It is the only one command about PHP which work. So, I think that the commands shown in the last posts are deprecated.

Solution 4 - Php

If brew link is not working for you, check your php version installed by:

ls /usr/local/opt/php*

Here, you will see a version as such:

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

Should give you an output like:

/usr/local/opt/php@7.3:
INSTALL_RECEIPT.json        include
LICENSE                     lib
NEWS                        pecl
README.md                   sbin
bin                         share
homebrew.mxcl.php@7.3.plist

Now you just need to link that to your $PATH which can be done as:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Note: I am using .zshrc because that is my terminal setup. If yours is bash, use accordingly.

You can check which version of php is now linked to your MacOS by running:

which php

This should give you an output of:

/usr/local/opt/[email protected]/bin/php

That's it. Now if you try composer update, it should not give you the extension issue.

Source (part of it): https://medium.com/@jjdanek/installing-php-extensions-on-mac-after-homebrew-acfddd6be602

Solution 5 - Php

2020-05-16 updated

Like @marc-alexander said, this is a bad practice. You should not use --ignore-platform-reqs option if you do not sure what you are doing.

I thought the option would ignore the platform requirements and install the specific version of the packages. But in fact it will ignore the platform requirements and install the highest available version of the packages.

So if you need the missing PHP extension, you should just install (or enable) it

Reference: ignore-platform-reqs installs dev-master instead of correct version

Original

If you do not need ext-zip (e.g. You just want to do some quick fix), you can use --ignore-platform-reqs option to ignore the requirements:

$ composer update --ignore-platform-reqs

Solution 6 - Php

This worked for me

brew update brew install [email protected] brew link [email protected] brew link [email protected] --force

Hope it helps

Solution 7 - Php

I had problems with python symlink during the brew install php.

/usr/local/Frameworks didn't exist so I had to create it: sudo mkdir /usr/local/Frameworks

cd /usr/local/

Then I had to chown it: sudo chown -R myuser:admin Frameworks

I based the permission settings on the rest of the folders in /usr/local.

Then I could run brew link python. Then I ran brew install php again and it completed.

php -v now gives me php 7.3.10 , before it was php 7.3.18 I think.

Solution 8 - Php

Instead of force linking you can also fix the problem in MacOS Catalina

by adding the php binary path to your bash profile e.g.:

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbinbin:$PATH"' >> ~/.bash_profile

Solution 9 - Php

In my case I had to simply

brew link --overwrite php

Solution 10 - Php

As other users already mentioned: This error usually means, that your PATH variable is not set up correctly, so some MAMP binaries are not found by the terminal.

Shell config

I use the following code in my .zshrc (or .bashrc) profile to set the correct PATHs for the current PHP version:

export PHP_VERSION=$(php -r 'echo PHP_VERSION;')
export PATH="/Applications/MAMP/Library/bin/:$PATH"
export PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH"
Details
  • export PHP_VERSION=$(php -r 'echo PHP_VERSION;') this line fetches the PHP version from the current PHP interpreter. After that, you can access $PHP_VERSION in any shell script.
  • export PATH="/Applications/MAMP/Library/bin/:$PATH" this is a standard path that I need for MAMP integrations to work
  • export PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH" this is the important part, which adds the correct phpX.Y.Z folder to the path list. This line uses the $PHP_VERSION which we fetched in the first line above.
Check

After adding the above snippet to .zshrc (or .bashrc) you need to load the updated shell profile by running the following command

source ~/.zshrc   # or ~/.bashrc

Finally, you can do a quick check so see if the PATH values are correct:

echo -e ${PATH//:/\\n}

# Output:
...
/Applications/MAMP/bin/php/php7.4.12/bin/    ← this line contains the PHP version
/Applications/MAMP/Library/bin/
...

Solution 11 - Php

i know this thread has true answered, i do those with this approach :

  1. brew link [email protected] it is showing hint to using
    echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc

  2. in terminal, echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc enter

  3. in terminal, echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc enter

  4. next execution this : source ~/.zshrc

  5. execution which php the results must show /usr/local/opt/[email protected]/bin/php

  6. try again composer update, if show Allowed memory size of 1610612736 bytes exhausted (tried to allocate 4096 bytes) in phar:///usr/local/Cellar/composer/1.9.2/bin/composer/src/Composer/DependencyResolver/RuleWatchGraph.php on line 52 please change php.ini limit with memory_limit = -1

  7. try search php.ini, type in terminal /usr/local/opt/[email protected]/bin/php --ini , the results must show: Configuration File (php.ini) Path: /usr/local/etc/php/7.3 Loaded Configuration File: /usr/local/etc/php/7.3/php.ini Scan for additional .ini files in: /usr/local/etc/php/7.3/conf.d Additional .ini files parsed: /usr/local/etc/php/7.3/conf.d/ext-opcache.ini

  8. nano /usr/local/etc/php/7.3/php.ini, append memory_limit =-1,save

  9. restart php

  10. re-execution composer update.

Hope my answer can help you.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAbdulView Question on Stackoverflow
Solution 1 - PhpAldranorView Answer on Stackoverflow
Solution 2 - PhpHamza WaleedView Answer on Stackoverflow
Solution 3 - PhpInfiniteRoadsView Answer on Stackoverflow
Solution 4 - PhpSAVE.US_222View Answer on Stackoverflow
Solution 5 - PhpSteven ChenView Answer on Stackoverflow
Solution 6 - PhpHabib MammadovView Answer on Stackoverflow
Solution 7 - PhptommyskottView Answer on Stackoverflow
Solution 8 - PhpMDeuerleinView Answer on Stackoverflow
Solution 9 - PhpJoão Felipe Marques RibeiroView Answer on Stackoverflow
Solution 10 - PhpPhilippView Answer on Stackoverflow
Solution 11 - PhpbanzaiView Answer on Stackoverflow