How to change the php version for the console

Many a times when you view the php version in the browser by displaying the phpinfo() information and the php version that is displayed when you see by typing the command “php -v” in the console or command prompt, You will notice that there is difference in the two.

So how  to set the php version same as the version that you see in your phpinfo( ) function in the browser.

Step 1: Find the path to the executable of the php from the phpinfo() displayed in the browser. For example, if you have ampps installed you will find the path as “/Applications/AMPPS/php-7.1/bin/php”. 

Incase you have multiple version of php configured then choose the binary/executable path to the required version of php.

For example for php5, the path would be “/Applications/AMPPS/php5/bin/php”.

Step 2: Setting the php version for the console

Once you have decided upon the required php version for your console application execute the below command.

alias php=’/Applications/AMPPS/php-7.1/bin/php’ => This will set your php version to 7.1 for you console command line instruction.

Similarly for php5

alias php=’/Applications/AMPPS/php5/bin/php’

To make this work,You need to double check the location of the required php executable path, then only it will work. If you don’t have the required version installed. you could installed it as per your need and the operating system you are using.

 

Leave your comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.