PHP 7 on Mac OS command line

Sometimes, when for example doing unit tests with phpunit 5, you will need a newer PHP version. The bundled Apple PHP version is 5.5 in El Capitan, which is quite outdated.

Installing another PHP version is quite easy. We can just use brew for it.

brew install php70 --with-mysql --with-mysqli

And you probably also want XDebug, so let's install that too:

brew install php70-xdebug

Check with:

php --version

That you now use the new PHP 7.0 version. If not create an alias:

alias php='/usr/local/bin/php'

You can also add this to your .zshrc or .bashrc