0

My php version is PHP 7.4.1.

But with MAMP, the highest possible php version I can use is 7.3.8.

So, when I try to open my webpage, I get the error message:

Fatal Error: composer.lock was created for PHP version 7.4 or higher but the current PHP version is 7.3.8.

How can I downgrade my php version to fit to my MAMP version?

I tried:

brew install php@7.3

It was installed, but when I now write php --version, I get the error:

-bash: /usr/local/bin/php: No such file or directory

xxx
  • 1,153
  • 1
  • 11
  • 23
peace_love
  • 6,229
  • 11
  • 69
  • 157
  • 1
    You can use your MAMP's PHP version to your command line's PHP. just link it – Muhammad Dyas Yaskur Dec 29 '19 at 13:46
  • @ I made now `brew unlink php` and then `brew link --overwrite php@7.3 --force`. Now the php version is `7.3.13` but how can I get `7.3.8` ? – peace_love Dec 29 '19 at 14:07
  • when I write `brew install php@7.3.8` I get the error `No available formula with the name "php@7.3.8"` – peace_love Dec 29 '19 at 14:15
  • I think you're reading the error backwards. It says "the current PHP version is 7.3.8" but your composer.lock file requires 7.4 or higher. Doesn't that mean you actually need MAMP to use a 7.4.* version? – rickdenhaan Dec 29 '19 at 14:16
  • @rickdenhaan Yes this would be great, but the highest Version available for Mamp is 7.3.8 – peace_love Dec 29 '19 at 14:23
  • 1
    Ok, so the underlying problem is that you ran `composer install` or `composer update` with the wrong PHP version. If you follow the steps in @MuhammadDyasYaskur's answer, composer should use the MAMP PHP version as well and you can re-generate the `composer.lock` file with the correct PHP version (you might need to delete the file first) – rickdenhaan Dec 29 '19 at 14:29

2 Answers2

2

you don't need brew's PHP if you want to use MAMP's PHP.

just use Applications/MAMP/bin/php7.3.8/bin/php --version to use MAMP PHP, if you want to use as default command line, just link it to /usr/bin.

to link it run this to your command line:

export MAMP_PHP=/Applications/MAMP/bin/php/php7.3.8/bin
export PATH="$MAMP_PHP:$PATH"

or

PHP_VERSION=`command ls /Applications/MAMP/bin/php/ | sort -n | tail -1`
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH

check it out for more detail.

PS: Maybe you should delete your brew php to do it.

Muhammad Dyas Yaskur
  • 6,914
  • 10
  • 48
  • 73
0

First

$ brew update

and

$ brew upgrade php
Immeyti
  • 545
  • 3
  • 15