How to Install PHP 7.2 (and 7.1, 7.4 etc) on MacOS Monterey
As PHP older versions have now been deprecated upstream you will encounter
errors when trying to to install via Homebrew. For example, attempting to
install PHP 7.2 will give the following:
Error: php@7.2 has been disabled because it is deprecated upstream!
There’s a tap you can use at shivammathur/php
which has all of the older
versions that are still installable.
First, tap the repo:
brew tap shivammathur/php
and then install the PHP version you want:
brew install shivammathur/php/php@7.2
Give it a few minutes to go off and do it’s thing and you’ll then have the
desired version running locally. I can understand why the PHP deprecated the
older versions but there’s an awful lot of developers out there who will
still need to run and install older versions of PHP due to constraints they
are under.