Switch between multiple PHP versions on your mac

This article is a slimmed-down, firing-from-the-hips, get right to the action version based on the ones listed below. If you miss some background info or want a more spelled out version, please do visit these articles:

Install multiple PHP versions with fpm

I’d also install the xdebug extension.

If you receive the error configure: error: Cannot find libz you need to install required libraries via XCode:

Switch PHP-version

To switch the active version of PHP use the command sphp (script for this command is further down below):

Without arguments, this command returns useful information like which versions are installed and which is the active one right now:

Create script for easy switching

In order for this to work, create the following script: /usr/local/bin/sphp