Brew
Homebrew is the missing package manager for macOS.
Getting started
# Install.
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Find where Homebrew lives (/usr/local on Intel, /opt/homebrew on Apple silicon).
brew --prefix
Bash completion
# Check if git completions exist.
ls $(brew --prefix)/etc/bash_completion.d/ | grep git
# You should get something like the following:
git-completion.bash
git-prompt.sh
Install the loader and source it from ~/.bash_profile so those completions get picked up:
brew install bash-completion@2
echo '[[ -r "$(brew --prefix)/etc/profile.d/bash_completion.sh" ]] && . "$(brew --prefix)/etc/profile.d/bash_completion.sh"' >> ~/.bash_profile
Manage packages
# List installed packages matching a name.
brew list | grep php
# Search for available packages.
brew search php
# Get info on a package.
brew info php
# Install.
brew install php
# Verify.
php --version
# Uninstall.
brew uninstall php
Switching PHP versions
Versioned formulae live alongside the default one. To move from PHP 8.3 to 8.4, for example:
brew uninstall php@8.3
brew install php@8.4
Homebrew leaves configuration files behind on uninstall and tells you where:
Warning: The following may be php@8.3 configuration files and have not been removed!
If desired, remove them manually with `rm -rf`:
/opt/homebrew/etc/php/8.3
Remove them once you are sure you no longer need that version:
rm -rf "$(brew --prefix)/etc/php/8.3"