Running With Multiple Versions of php Posted on September 7th, 2017
My day job requires that I work on a variety of projects. A few of the older projects have yet to be migrated to php 7 while newer projects are written on 7.1. Do to system constraints on composer, I have both php 5.6 as well as 7.1 installed on my machine. However when I run
composer ..., it uses my default php is 7.1. To get composer working, I'd have to look up where the 5.6 binary was and run
/path/to/5.6/binary composer. The other day, I finally had enough of this an added these aliases to my
alias php56="`(brew --prefix homebrew/php/php56)`/bin/php" alias composer56="php56 `which composer`"
The first alias,
php56, is an alias to the php 5.6 binary. The second alias,
composer56 prefixes the php 5.6 binary path to the composer executable.