I was trying to use Phan, a PHP code analyser, on my Macbook, but it’s requiring PHP 7 cli. I never modified the PHP cli on my machine, mainly because I use MAMP to handle different environments. But here I had no choice. Here is the way I handled it.

Easy trick : use aliases

Yeah, it’s way too easy that way, just create an alias from your command line pointing to a php bin. In my case, I made it point to php7 bin from MAMP.

Note : you can name it whatever you want. php7 could be a good option too. 😉

To remove the alias :

To make the changes effective, either close and open your terminal again, or type in

Cleanest way : using brew

If you have Homebrew installed on your machine, it’s pretty easy to install whatever version of PHP with it. And it’ll take care of every cli bins.

In my case, I had a 5.5 version of PHP already installed, so I need to tell brew to unlink it before installing another one

And then, let brew do the dirty work for you

Et voilà !