I have installed MAMP (comes with PHP 5.5) on my machine. And localhost pointed to /Applications/MAMP/htdocs. The problem happened when I was trying to use composer in terminal to install dependencies in htdocs. Composer complained that PHP must be 5.4 or above.
I guess it complained about PHP comes with OSX. So I have upgraded PHP to 5.6 by
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
But when I do
$ php -v
I still get
PHP 5.3.28 (cli) (built: Aug 29 2014 18:52:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
And Composer is still complaining...
Why is that? And how to fix this?
If you have upgraded using curl, copy & paste the following line of code and press enter.
$ export PATH=/usr/local/php5/bin:$PATH
Now, type
$ php -v
If done correctly, it should show the following
PHP 5.6.23 (cli) (built: Jun 26 2016 13:17:47)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
If you installed PHP 5.6 using Homebrew, this works:
Open Terminal, run open -a TextEdit ~/.bash_profile
, then paste this in the end of the file:
# Use Home-brewed PHP 5.6 instead of pre-installed version (5.3)
export PATH="$(brew --prefix homebrew/php/php56)/bin:$PATH"
Save the file and restart Terminal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With