sweikenb

Simon Schröer

Ab blog about software-development and potentially interesting things.

macOS: Install PHP with Homebrew in 2024

Install general deps:

# Xcode
xcode-select --install

# Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Install php taps for extended version ranges and extensions:

brew tap shivammathur/{php,extensions}

Install PHP versions you want:

brew install shivammathur/php/php@{8.3,8.2,7.4}

Choose default php version:

brew unlink php

brew link shivammathur/php/php@8.3 --force

Install PHP extensions:

# PHP 8.3
brew install shivammathur/extensions/{apcu@8.3,uuid@8.3,xdebug@8.3}

# PHP 8.2
brew install shivammathur/extensions/{apcu@8.2,uuid@8.2,xdebug@8.2}

# PHP 7.4
brew install shivammathur/extensions/{apcu@7.4,uuid@7.4,xdebug@7.4}

An overview of all available extension can be found here.