install ext-zip for Mac

115,485

Solution 1

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

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

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

Following command fixed the issue on macOS Catalina

brew link [email protected] --force

Solution 3

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

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 5

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/[email protected]:
INSTALL_RECEIPT.json        include
LICENSE                     lib
NEWS                        pecl
README.md                   sbin
bin                         share
[email protected]

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

Share:
115,485
Abdul
Author by

Abdul

Updated on May 26, 2021

Comments

  • Abdul
    Abdul almost 3 years

    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.

  • Jamie Robinson
    Jamie Robinson over 4 years
    @Aldranor feel like this almost works, running a brew install sounds like a good plan. However, now getting "Error: Could not symlink sbin/php-fpm" "/usr/local/sbin is not writable."... brew won't run sudo either... any ideas?
  • Jamie Robinson
    Jamie Robinson over 4 years
    Finally fixed it! Running "brew doctor" says that this folder doesn't exist and isn't writable, and gives you the commands to run. Run those commands, run the link command again, reload the console, all back to normal :)
  • Bakhtiyor
    Bakhtiyor over 4 years
    Thanks a lot @Aldranor. Worked on my MacOS Catalina like a charm. Bug fixed :)
  • Ben Spi
    Ben Spi over 4 years
    I would propose to use ---> sudo chown -R $(whoami) bin etc include lib sbin share var Frameworks <---- instead of ---> sudo chown -R myuser:admin Frameworks <---
  • leeCoder
    leeCoder over 4 years
    use 'brew link --force [email protected]' if you see this warning "[email protected] is keg-only and must be linked with --force"
  • Loosie94
    Loosie94 over 4 years
    This worked, but only after i've added: export PATH="/usr/local/opt/[email protected]/bin:$PATH" export PATH="/usr/local/opt/[email protected]/sbin:$PATH" to my .zshrc
  • shivanisdev
    shivanisdev about 4 years
    Then reload your console. is very important I missed to close and open the terminal and struggled for hours.
  • clarmond
    clarmond about 4 years
    If --force doesn't work, try this: brew unlink [email protected] && brew link --force [email protected]
  • Dany Balian
    Dany Balian about 4 years
    If --force doesn't work.. it might be that the php folder is unwritable.. run: sudo chown -R $(whoami) /usr/local/lib/php then retry
  • Travis L
    Travis L about 4 years
    I had to run echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.bash_profile but seemed to work after
  • Scott Cantrell
    Scott Cantrell about 4 years
    Beautiful! Much obliged!
  • Marc Alexander
    Marc Alexander almost 4 years
    Bad practice. Then composer may not install everything correctly / skip over stuff.
  • Steven Chen
    Steven Chen almost 4 years
    Thanks for your comment! I did some Google search on the topic and I found you are right. I will modify my answer.
  • John Blanchard
    John Blanchard almost 4 years
    This is the only thing that worked for me - Thanks!
  • Mahesh Samudra
    Mahesh Samudra over 3 years
    If you get an error message when trying to link the php version with brew, just use brew link [email protected] --force Kudos to Hamza Waleed
  • jpswade
    jpswade over 3 years
    Don't forget to do brew unlink php && brew link php as well as ensure you're using the right php binary, ie: /usr/local/bin/php
  • Saitama
    Saitama almost 3 years
    @Loosie94 Working perfectly.
  • Valkay
    Valkay almost 3 years
    Works as advertised
  • Shuvo Joseph
    Shuvo Joseph almost 3 years
    Error: No such keg: /usr/local/Cellar/[email protected]. Any suggestion ?
  • Krishna Karki
    Krishna Karki almost 3 years
    MAMP php version and the system version can be different so its better to keep php version static. export PHP_VERSION="7.4.12"
  • Abaij
    Abaij almost 3 years
    if you are using big sur, you have to use [email protected] instead of 7.3 as php 7.3 is not supported anymore
  • Fred
    Fred almost 3 years
    Worked great! Thanks!
  • user3072843
    user3072843 almost 2 years
    In case you see a keg-error try to install it in another way: ´brew tap shivammathur/php brew install shivammathur/php/[email protected] brew link [email protected]´