Good news! PHP 7.1 is being actively supported through 21 Nov 2024. After that point, it's advisable to upgrade to the latest version, since the PHP team will only offer security-related support until 21 Nov 2024, at which point PHP 7.1 will be considered "end-of-life".
Open Terminal
Install Homebrew if not already installed:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Add the PHP tap to Homebrew:
brew tap shivammathur/php
Install PHP 7.1:
brew install shivammathur/php/[email protected]
Link PHP 7.1:
brew link [email protected] --force
Check PHP version:
php -v
You should see output indicating PHP 7.1.x is installed.
Verify PHP configuration:
php -i
This will display detailed PHP configuration information.
Test PHP by creating a simple PHP file:
echo '<?php phpinfo(); ?>' > phpinfo.php
php phpinfo.php
This should display PHP configuration information in your terminal.