So, you mean to highlight all pieces of code that will not work with the PHP version you are writing it in, right? That can be done here:

Preferences -> Languages & Frameworks > PHP

and the same on Mac:

PhpStorm -> Preferences (⌘,) -> Languages & Frameworks > PHP

Or with newer versions of PhpStorm in Windows:

File -> Settings -> Languages & Frameworks > PHP

then select your PHP version, for example, 7.0

This is very useful when your local system runs PHP 7.0, for example, but production is running PHP 5.5.

That way PhpStorm will warn you which parts will not work in production, show proper hints during writing code according to the selected version, etc.

Answer from Alejandro Moreno on Stack Overflow
🌐
Reddit
reddit.com › r/phpstorm › unexpected/incorrect php version when running unit tests
r/phpstorm on Reddit: Unexpected/Incorrect PHP Version when running unit tests
June 27, 2022 -

Hi, probably me doing something stupid but after much google-fu and delving in storm's preferences I still cannot crack it.

I am running a mac and use brew to install / switch between multiple PHP versions. In terminal I am running the expected PHP version (8.1):

$ which php

/opt/homebrew/opt/php/bin/php

$ /opt/homebrew/opt/php/bin/php -v

/opt/homPHP 8.1.7 (cli) (built: Jun 9 2022 14:08:46) (NTS)

Copyright (c) The PHP Group

Zend Engine v4.1.7, Copyright (c) Zend Technologies

with Xdebug v3.1.5, Copyright (c) 2002-2022, by Derick Rethans

with Zend OPcache v8.1.7, Copyright (c), by Zend Technologies

In Preferences -> PHP

I have PHP language level set to 8.1 and CLI Interpreter to my 8.1 executable location (which shows the correct version and xdebug version).

However, when I run my unit tests it is using my php 7.4 version.

Discussions

macos - PhpStorm + XAMPP not showing latest PHP version in command line - Stack Overflow
This is not a 100% solve but it solves my problem. Since it was only the command line tools where the wrong php version was being used, I am now using the embedded terminal in phpstorm instead of the command line tool. More on stackoverflow.com
🌐 stackoverflow.com
July 27, 2017
Wrong PHP version when executing composer scripts
Do you mean something like this? sudo update-alternatives --config php More on reddit.com
🌐 r/phpstorm
4
1
March 21, 2024
ide - PhpStorm ignores PHP version setting in project - Stack Overflow
Remember that PhpStorm displays the version of the PHP engine detected in the specified folder and the debugger associated with this PHP engine in the php.ini file. So you must have something wrong on there. More on stackoverflow.com
🌐 stackoverflow.com
Using PHP as CLI Interpreter in PhpStorm
Issue Summary I would like to use the version of PHP tied to the site in LocalWP in PhpStorm as the CLI Interpreter for things like Composer and PHPUnit. If I open the shell, run which php, and then paste that URL into PhpStorm for the interpreter it almost works. More on community.localwp.com
🌐 community.localwp.com
3
0
December 3, 2021
🌐
YouTrack Support
youtrack-support.jetbrains.com › hc › en-us › community › posts › 360010604219-PHP-CLI-in-terminal-don-t-changing-to-right-version
PHP CLI in terminal don't changing to right version – YouTrack Support | JetBrains
PHP interpreters in PhpStorm only affect PhpStorm itself, they don't modify the system environment. If you want to change the PHP version in the terminal, you should change your environment accordingly.
🌐
Phpjunior
phpjunior.com › change-php-version-phpstorm-terminal
change php version of phpstorm terminal
June 23, 2023 - after that you will have another php version listed in “CLI Interpreters” window. ... The final step is to change the “PATH” environment variable for terminal in phpstorm.
🌐
JetBrains
youtrack.jetbrains.com › issue › WI-33524 › different-php-version-in-phpstorm-command-line-and-mac-terminal
different php version in phpstorm command line and mac ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
JetBrains
jetbrains.com › help › phpstorm › supported-php-versions.html
Supported PHP versions | PhpStorm Documentation
January 8, 2026 - However, if you attempt to use a code construct that is not supported by the specified language level, PhpStorm suggests a Switch to PHP <version> quick-fix.
🌐
JetBrains
jetbrains.com › help › phpstorm › configuring-local-interpreter.html
Configure local PHP interpreters | PhpStorm Documentation
February 12, 2026 - The selected interpreter will be set as the default project interpreter on the PHP page of the Settings dialog (Ctrl+Alt+S) . This will also affect configurations that use the default project interpreter (test frameworks, quality tools, and run/debug configurations) and commands run in the PhpStorm terminal.
Find elsewhere
🌐
Michael Smith
mikesmith.us › home › development › ide › phpstorm › how to change current project php version in phpstorm 2022.2.2
How To Change Current Project PHP Version in PhpStorm 2022.2.2 - Michael Smith
October 3, 2022 - Now we just select the dropdown under heading PHP language level and choose which version you’re changing to. There is also a brief description of some of the new features next to each language level. For instance, with PHP 8.1, enumerations, ‘never’ return type, intersection types, and ‘readonly’ properties are all new features. And that’s it! Those are the two ways to update the current PhpStorm project’s PHP version.
🌐
Quora
quora.com › How-do-I-setup-PHP-7-in-PhpStorm
How to setup PHP 7 in PhpStorm - Quora
Answer: You have to change the path to PHP executable in Windows. System Properties > Advanced > Environment Variables - in the System Variables, select PATH and click Edit. Find the piece that refers to PHP 5, and change it to the path to the ...
🌐
JetBrains
youtrack.jetbrains.com › issue › WI-38683 › windows-phpstorm-change-terminal-php-version
windows: phpstorm - change terminal php version : WI-38683
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
Stack Overflow
stackoverflow.com › questions › 45338817 › phpstorm-xampp-not-showing-latest-php-version-in-command-line
macos - PhpStorm + XAMPP not showing latest PHP version in command line - Stack Overflow
July 27, 2017 - I am using OSX running on El Capitan and setting up PhpStorm and the Laravel environment has been a nightmare. I created a project setting up Composer and created it with laravel/laravel from the options menu. As you can see in the screen shot, the PHP version says 5.6.31.. but if I type php -v in the command line. It gives me php 5.5 (as shown in the bottom left) If I type php -v in the terminal I also get php 5.6.
🌐
Reddit
reddit.com › r/phpstorm › wrong php version when executing composer scripts
r/phpstorm on Reddit: Wrong PHP version when executing composer scripts
March 21, 2024 -

Hi, I need help when running my composer scripts. I'm using Laravel Pint as my formatter
and even though the machine is already using the correct php version, the output displays
a different version.

I have already configured phpstorm's cli interpreters, quality tools (laravel pint) and composer's PHP interpreter to the correct version. Anyone here also had the same issue? Thank you.

  • Version: 2023.3.5

  • Build: 233.14808.18

  • 11 March 2024

Edit: I found the issue, it does not detect what I set in phpbrew. I had to install php using apt, is there any way I can still use phpbrew?

🌐
JetBrains
jetbrains.com › help › phpstorm › settings-tools-terminal.html
Terminal settings | PhpStorm Documentation
March 12, 2026 - Unselect the checkbox if you want to use the system shell's default PHP version binary for running commands in the PhpStorm terminal.
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 360007659819-PhpStorm-doesn-t-recognize-my-PHP-CLI-executable
PhpStorm doesn't recognize my PHP CLI executable! – IDEs Support (IntelliJ Platform) | JetBrains
In cmd.exe I enter "php --version" and get this output: PHP 7.4.3 (cli) (built: Feb 18 2020 17:29:57) ( NTS Visual C++ 2017 x64 ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies · Restarting PhpStorm didn't help. ... OK, I should clarify that this is only a problem when editing IDE settings (i.e., at the welcome screen, go to Configure > Settings). When I open a project and go to settings it verifies my PHP installation.
🌐
JetBrains
youtrack.jetbrains.com › issue › WI-74994 › PHP-version-in-terminal-is-different-then-windows-command-line-since-v-2023.2.3
PHP version in terminal is different then windows ...
{{ (>_<) }} This version of your browser is not supported. Try upgrading to the latest stable version. Something went seriously wrong
🌐
GitHub
gist.github.com › landbryo › d009f7a5e3e066a98950453fec16c10b
Laragon Cmder in PHPStorm · GitHub
The path has to be C:\laragon\bin\cmder\cmder.bat -> PHPStorm's Settings > Tools > Terminal It works perfectly and looks like it has some Linux commands (maybe all) @gajosadrian Your technique also worked, but both mine and yours had the issue that when I change the PHP version from laragon and close and reopen the PHPStorm terminal, the php -v Command does not reflect the change in the PHP version in CLI.
🌐
GitHub
github.com › composer › composer › issues › 10282
Platform check uses wrong PHP version on Windows · Issue #10282 · composer/composer
November 13, 2021 - Hi! I've just been experimenting with the scripts options in composer.json and noticed that when running e.g. PHPUnit this way, I run into a PHP version mismatch: composer.phar is invoked with a specific PHP executab, usually from within PHPStorm but executes the script with the PHP found in PATH.
Author   codemasher