install ext-zip for Mac
PhpMacosComposer PhpCommand Line-InterfaceHomebrewPhp 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 workexport PATH="/Applications/MAMP/bin/php/php$PHP_VERSION/bin/:$PATH"
this is the important part, which adds the correctphpX.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 :
-
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
-
in terminal,
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
enter -
in terminal,
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
enter -
next execution this :
source ~/.zshrc
-
execution
which php
the results must show/usr/local/opt/[email protected]/bin/php
-
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 withmemory_limit = -1
-
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
-
nano /usr/local/etc/php/7.3/php.ini
, append memory_limit =-1,save -
restart php
-
re-execution composer update.
Hope my answer can help you.