ChatGPT解决这个技术问题 Extra ChatGPT

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.

That error just means your PHP does not have the php-zip extension installed.
Having the same issue, phpinfo says that it is installed... very odd... thanks Apple...
@JamieRobinson do let me know if you have found a fix please!
@Abdul best I've got so far is using "composer install --ignore-platform-reqs"... its not a solution but it gets around the problem in the short term
@JamieRobinson for your information, somebody replied with something which worked for me.

A
Aldranor

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.


@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?
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 :)
use 'brew link --force php@7.3' if you see this warning "php@7.3 is keg-only and must be linked with --force"
This worked, but only after i've added: export PATH="/usr/local/opt/php@7.3/bin:$PATH" export PATH="/usr/local/opt/php@7.3/sbin:$PATH" to my .zshrc
Then reload your console. is very important I missed to close and open the terminal and struggled for hours.
H
Hamza Waleed

Following command fixed the issue on macOS Catalina

brew link php@7.3 --force

This is the only thing that worked for me - Thanks!
I
InfiniteRoads

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.


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
S
SAVE.US_222

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/php@7.3/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/php@7.3/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/php@7.3/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/php@7.3/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


S
Steven Chen

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

Bad practice. Then composer may not install everything correctly / skip over stuff.
Thanks for your comment! I did some Google search on the topic and I found you are right. I will modify my answer.
H
Habib Mammadov

This worked for me

brew update brew install php@7.3 brew link php@7.3 brew link php@7.3 --force

Hope it helps


t
tommyskott

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.


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 <---
M
MDeuerlein

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/php@7.3/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/php@7.3/sbinbin:$PATH"' >> ~/.bash_profile

J
João Felipe Marques Ribeiro

In my case I had to simply

brew link --overwrite php

P
Philipp

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/
...

MAMP php version and the system version can be different so its better to keep php version static. export PHP_VERSION="7.4.12"
b
banzai

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

brew link php@7.3 it is showing hint to using echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc in terminal, echo 'export PATH="/usr/local/opt/php@7.3/bin:$PATH"' >> ~/.zshrc enter in terminal, echo 'export PATH="/usr/local/opt/php@7.3/sbin:$PATH"' >> ~/.zshrc enter next execution this : source ~/.zshrc execution which php the results must show /usr/local/opt/php@7.3/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 with memory_limit = -1 try search php.ini, type in terminal /usr/local/opt/php@7.3/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.


u
user3072843

The solutions above did not work for MacOS Big Sur. However, I cam to working solution:

Download latest tarbal at https://pecl.php.net/package/zip brew install pcre2 fix a symlink, but check the version of your php (which php) and pcre2 (which pcre2) in order to install zip-1.20.1 in step 4. ln -s /opt/homebrew/Cellar/pcre2/10.40/include/pcre2.h /opt/homebrew/opt/php@7.3/include/php/ext/pcre/pcre2.h sudo pear install ~/Downloads/zip-1.20.1.tgz

Result: Installing /opt/homebrew/Cellar/php@7.3/7.3.33_2/pecl/20180731/zip.so install ok: channel://pecl.php.net/zip-1.20.1 Extension zip enabled in php.ini

Restart apache: sudo apachectl restart Make sure that the location of php used by apache and the one used in your terminal is the same (MacOS homebrew!). Therefore, execute which php in the terminal and open a php file with the following command in your browser: exec('which php'). Make sure that in the httpd.conf file php path links the right php version!