Homebrew is the missing package manager for Mac OS.

Getting Started

# Install
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

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

Manage packages

NOTE: This is for illustration purposes only. Do not install php5 anymore.

# List php packages
brew list | grep php

# Get info
brew info php55

# Uninstall
brew uninstall php55

# Search for available packages
# Should find homebrew/php/php56
brew search php

# Tap repo so brew knows where to find formulae
brew tap homebrew/php

# Install
brew install php56

# Verify
php -version
PHP 5.6.29 (cli) (built: Dec  9 2016 07:03:56)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Upgrading from PHP 7.2 to PHP 7.3

Uninstall

Just a couple of steps to uninstall 7.2:

brew uninstall php@7.2
Uninstalling /usr/local/Cellar/php@7.2/7.2.31... (515 files, 74.8MB)

Warning: The following may be php@7.2 configuration files and have not been removed!
If desired, remove them manually with `rm -rf`:
  /usr/local/etc/php

Remove files

rm -rf /usr/local/etc/php/

Install

One step to install 7.3:

brew install php@7.3