vn1iqg
Last Updated: February 25, 2016
·
9.11K
· MarcQualie
Ab35533b9cbf7a608283c3f1e89cf8d4

Fast Switching PHP on OS X

This is little snippet of aliases I use on OS X to switch quickly betwen multiple PHP installes with Homebrew. You can install all of the below versions of PHP via the Homebrew tap josegonzalez/homebrew-php.

This is a quick way to install all versions

brew tap josegonzalez/php
brew install php53 --with-fpm
brew install php54 --with-fpm
brew install php55 --with-fpm

These are the aliases that will auto switch to the version you want to use.

alias use_php53="brew unlink php54 && brew unlink php55 && brew unlink php53 && brew link php53"
alias use_php54="brew unlink php53 && brew unlink php55 && brew unlink php54 && brew link php54"
alias use_php55="brew unlink php53 && brew unlink php54 && brew unlink php55 && brew link php55"

Below is an extended version I use when I'm controlling FPM services via Supervisor.

alias use_php53="brew unlink php54 && brew unlink php55 && brew unlink php53 && brew link php53 && supervisorctl restart php5-fpm"
alias use_php54="brew unlink php53 && brew unlink php55 && brew unlink php54 && brew link php54 && supervisorctl restart php5-fpm"
alias use_php55="brew unlink php53 && brew unlink php54 && brew unlink php55 && brew link php55 && supervisorctl restart php5-fpm"

There you have it, a very simple but highly affective way of fast switching between php installs.

Say Thanks
Respond

5 Responses
Add your response

7627
736212 10200976756252420 836055407 o

I think this is better approach: https://github.com/c9s/phpbrew

over 1 year ago ·
7631
Ab35533b9cbf7a608283c3f1e89cf8d4

I agree that's a more advanced and fine tuned approach, it just takes a while to install/configure the way you want. My solution is designed as copy/patse drop-in for people already using Homebrew to manage PHP

over 1 year ago ·
10929
E94fe56c4c91d9af369ca8d2aa704c7a

I've done something very similar, although I extended it to use a symlinked libphp5.so and the corresponding bin folder from the active php version.

https://gist.github.com/dongilbert/7492449

over 1 year ago ·
12727
386b2a9bdc91823e4688f0dcbdd2f9fb

Here's my take on the matter. Simple. But not as powerful as phpbrew, because of its inherent simplicity:
https://github.com/conradkleinespel/sphp-osx

over 1 year ago ·
22287
Rrnknql6 normal

I followed this tutorial but only CLI version was changed not the PHP version from server (<?php phpinfo() ?>
How to fix this? FYI, I am using LEMP stack.

over 1 year ago ·
Filed Under