31

I want to install PHP 7.2 on MacBook Pro M1, macOS Big Sur (11.5.2).

I already read an article (How To Install a PHP 7.2 on macOS 10.15 Catalina Using Homebrew and PECL), but it doesn't work for me.

I used Homebrew to install PHP 7.2 using this command:

brew install php@7.2

But I've got this error:

php@7.2 has been disabled because it is deprecated upstream!
nekofar
  • 1,497
  • 1
  • 18
  • 25
mustafa hasria
  • 460
  • 1
  • 4
  • 14
  • 3
    "but he is also use same command" - yes, but not on an M1 and in 2019. Things get deprecated in three years. – Sergiu Paraschiv Dec 05 '21 at 18:20
  • 2
    PHP 7.2 reached [end of life](https://www.php.net/eol.php) over a year ago. Brew won't install it for you because it is very out of date and doesn't get security updates. It's dangerous to use and you should upgrade instead of trying to use it. – Quentin Dec 05 '21 at 18:21
  • I doubt that MacOS will allow you to install [unsupported versions of php](https://www.php.net/supported-versions.php) – Pieterjan Dec 05 '21 at 18:21
  • but the project i use depending on this verions of PHP how can i solve this matter – mustafa hasria Dec 05 '21 at 18:34
  • 1
    ``brew tap exolnet/homebrew-deprecated`` then ``brew install php@7.2`` should install. – OMi Shah Dec 05 '21 at 18:58
  • Your project will probably run in slightly higher version which is still supported. If not, it needs some updates to it, in order to remain current and supportable. – ADyson Dec 05 '21 at 19:37

2 Answers2

78

Since PHP 7.2 is not supported anymore, it's got delisted from the Hombrew core repository.

You've to find a third-party repository that still contains an older PHP version, such as the shivammathur/php repository.

You need to tap the repository like this in your Homebrew:

brew tap shivammathur/php

Then you can install PHP 7.2 like this:

brew install shivammathur/php/php@7.2

You can find more information around the above tap and available versions on its GitHub repository.

nekofar
  • 1,497
  • 1
  • 18
  • 25
0

These worked for me

rm -rf $(brew --repo homebrew/core)

brew tap homebrew/core

brew install php

Judith lobo
  • 131
  • 4