Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Mac's terminal to use Brew's PHP version?

I'm currently trying to get PHP 7.1 on my mac. I followed this guide and successfully installed and linked php71 https://developerjack.com/blog/2016/08/26/Installing-PHP71-with-homebrew/

However, when running php -v from the terminal (after restarting computer, after running source bashprofile etc.), I still get PHP 5.6.30 (cli). Is there a way to get the terminal to use brews install instead of the version that comes with mac?

like image 228
Guybrush Avatar asked Nov 30 '25 01:11

Guybrush


1 Answers

Various ways:

  • make a softlink from your php location to /usr/local/bin e.g. ln -s /usr/local/Cellar/php /usr/local/bin/php and make sure /usr/local/bin is before /usr/bin in your path variable.
  • make an alias in .bash_profile (restart your terminal) alias php = /yourpath
like image 193
Maarten van Middelaar Avatar answered Dec 01 '25 15:12

Maarten van Middelaar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!