Install PHP 8.2 on Mac with homebrew


Installing PHP 8.2 on your Mac using Homebrew is pretty straightforward. As a WordPress developer, you’ll probably find this handy for your local development environment. Here’s a step-by-step guide:

  1. Open Terminal: You’ll be using the Terminal to run all the necessary commands.
  2. Check Homebrew: If you haven’t installed Homebrew yet, you’ll need to do that first. Run the following command:
   /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  1. Update Homebrew: Make sure Homebrew is up-to-date by running:
   brew update
  1. Tap the PHP Repository: If you haven’t tapped the PHP repository already, do so with this command:
   brew tap shivammathur/php
  1. Install PHP 8.2: Now you can install PHP 8.2 with:
   brew install shivammathur/php/php@8.2
  1. Link PHP Version (Optional): If you want to set PHP 8.2 as your default version, you can link it:
   brew link --overwrite --force php@8.2
  1. Verify Installation: Check the installed PHP version to make sure everything went smoothly:
   php -v

You should see information about PHP 8.2, indicating that the installation was successful. If you run into any issues, Homebrew’s error messages are usually pretty informative, so they might guide you toward a solution. Enjoy your development with the latest PHP version!