Mac upgraded PHP to 5.6, but will CLI php -v get 5.3.28?

I installed MAMP (comes with PHP 5.5) on my machine. And localhost pointed to / Applications / MAMP / htdocs. The problem arose when I tried to use the composer in the terminal to install dependencies in htdocs. The composer complained that PHP should be 5.4 or higher.

I assume that he complained that PHP comes with OSX. So I upgraded PHP to 5.6 on

curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6 

But when I do

 $ php -v 

I'm still getting

 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 the composer is still complaining ...

Why? And how to fix it?

+6
source share
4 answers

If you upgraded using curl, copy and paste the following line of code and press enter.

$ export PATH = / usr / local / php5 / bin: $ PATH

Now enter $ php -v

If done correctly, it should show the following

PHP 5.6.23 (cli) (built: June 26, 2016 13:17:47) Copyright (c) 1997-2016 PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, Zend Technologies with Xdebug v2.2.5, Copyright (c) 2002-2014, Derick Rethans

+20
source

If you installed PHP 5.6 using Homebrew , this works:

Open a terminal, run open -a TextEdit ~/.bash_profile , then paste it at 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 the terminal.

+9
source

Thanks for the help.

This is due to the order in $ PATH, for example, with Marc and jkj posted in the comments above.

I canโ€™t find a way to reorder $ PATH (I did some research, but couldnโ€™t find a simple way), but I can fix this by simply removing Apahce2 previously installed after this message:

https://apple.stackexchange.com/questions/41143/how-to-revert-default-mac-apache-install-to-original

9/9/2014 update: after some research, the following procedure will make the installation of the PHP version wider.

The procedure comes from this source , please find the comments below this page and find the user Amtriorix.

I just copy / paste its solution here:

  The php-cli version is still the Apple version if You do not change it. Your php on apache can be different as the cli version, including used modules ! So beware. As Brian Wynn did mention, of course You can modify Your PATH settings to write into your ~/.profile file the following export PATH=/usr/local/php5/bin:$PATH Most likely a better approach is to make the setting system wide. You should symlink to the right php executable. So: #cd /usr/bin #mv php php.org #ln -s /usr/local/php5/bin/php test if it works: #php -v && php -m && php --ini --> should be php-osx version with related modules... 
+3
source
  • Look at the terminal history to find out where the new version was installed (possibly / usr / local)
  • Type 'php' into the terminal to see where the current version is (this should be different than the new version)
  • Go to users / username /.bash_profile
  • Replace the old location with a new location or add another location after the original location, separated by a colon (if you replace it, you may break something else, depending on the location).
  • Reboot the terminal, run php -v for testing.

     export PATH="/usr/local/mysql/bin:/usr/local/bin:/usr/local:$PATH" 
0
source

Source: https://habr.com/ru/post/974994/


All Articles