How to install PHP 7.2 on macOS Big Sur using Homebrew?

Viewed 17575

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!
1 Answers

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.

Related