On the command line, run the following commands:
# Download and install Homebrew.
curl -o- https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh | bash
# Install and link PHP.
brew install php@= $version; ?>
brew link --force --overwrite php@= $version; ?>