changing php version in local web server doesn’t change the version in the command line terminal of an IDE like PhpStorm.
here I changed the php version in laragon but the version in phpstorm terminal stays the same.
you can check it with
php -v command
to change that we go to File-> Settings -> PHP .
you can see that “PHP language level” and “CLI interpreter” are at 8.1.
we have to change the CLI Interpreter. for doing that, click on the button with three dots(…)
then at the new window click on the “+” sign at top left corner. then click on “Other Local”.
here you can choose the php version you want for the cli.
after that you will have another php version listed in “CLI Interpreters” window.
you can select that as the php version for cli.
change terminal environment variables
The final step is to change the “PATH” environment variable for terminal in phpstorm.
to do that go to File -> Settings -> Tools -> Terminal
at the right side you see Environment variables input. click on the button next to it.
at the bottom look for the Path variable.
double click on the value and copy it to a text editor like Notepad.
search for the word “php” and you will find the path to the PHP version.
change it to the path that you want and exists in php folder.
now copy this and paste it in the Path value in phpstorm environment variables. then click ok
use php -v and check the version now. it will be the correct version you chose.