installphp.info


← Back to home page

Install PHP 8.2 on macOS 12

This version of PHP is actively supported.

Good news! PHP 8.2 is being actively supported through 31 Dec 2024. After that point, it's advisable to upgrade to the latest version, since the PHP team will only offer security-related support until 31 Dec 2026, at which point PHP 8.2 will be considered "end-of-life".

Installing PHP 8.2 on macOS 12

Prerequisites

  • macOS 12 (Monterey) or later
  • Command Line Tools for Xcode
  • Homebrew package manager

Installation

  1. Open Terminal

  2. Update Homebrew:

    brew update
  3. Install PHP 8.2:

    brew install [email protected]
  4. Link PHP 8.2:

    brew link [email protected]
  5. Add PHP to your PATH by adding the following line to your ~/.zshrc or ~/.bash_profile:

    export PATH="/usr/local/opt/[email protected]/bin:$PATH"
  6. Reload your shell configuration:

    source ~/.zshrc

    or

    source ~/.bash_profile

Verification

  1. Check PHP version:

    php -v

    You should see output indicating PHP 8.2.x

  2. Verify PHP configuration:

    php -i

    This will display detailed PHP configuration information

  3. Test PHP execution:

    php -r "echo 'PHP 8.2 is working!';"

    This should output: PHP 8.2 is working!