Macbook Update PHP Version Globally

Macbook Update PHP Version Globally

Posted on:July 24, 2019 at 10:00 AM

If you are using MacBook and you want to update your current PHP version, it might be troublesome for you in some cases. There are many ways to update php version in mac, however, today I will show you how to update PHP version globally.

Currently, I am using PHP 7.1 version on my machine. If you are using 5x, don’t worry, it gonna be working for you too.

Install PHP

I am using brew to install PHP. Run the following command in your terminal-

brew install [email protected]

Sidenote: Just keep in your mind, you can change PHP version whatever you need. For example, [email protected] or [email protected].

Set required PHP to your PATH

Once you have installed PHP successfully, now you need to set the required PHP to your PATH. Run the following commands.

echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.bash_profile
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

It there is no issues, now is the time to check PHP version. To check the PHP version, run any of the following commands.

php -v
php --version

Hopefully, you will get your desired PHP version.

Thank you.