Questions & Answers

how to change the version of php in vscode?

I'm using iis and vscode to do php work. I recently updated iis from php7.3 to php7.4. My problem is that vscode is still using php7.3. I googled how to change the version in vscode and almost all the resources say that there's a JSON file that can changed under php settings in File > preferences > settings. When I search for php I'm not seeing any of these options. What am I doing wrong?

enter image description here

enter image description here

2023-01-19 23:01:13
"Edit in settings.json" should be it
2023-01-19 23:01:13
Have you installed the php extension in your vs code ?
Answers(4) :

While you can set the version for the intelephense addon, this won't help much because it appears that this setting doesn't apply to VSC itself. However you can set the php.validate.executablePath setting to the path to your php.exe file, for example "php.validate.executablePath": "C:/wamp64/bin/php/php7.4.9/php.exe". This should override a possibly wrong php path VSC takes from the system PATH env setting when php.validate.executablePath is not set.

You can set the value directly as seen in your screenshot. Entry is named PHP Version. If you do so for that particular workspace, a file will be created at


If you don't see the folder .vscode in Explorer, you have to change the settings in Explorer to see hidden folders.

If you did set the PHP version on the page in your screenshot for that particular workspace then you should find in settings.json an entry that looks like the following

  "intelephense.environment.phpVersion": "8.1.0"

change that to

  "intelephense.environment.phpVersion": "7.4.0"

If you want to change the setting globally for all of your projects you can do the the following:

Open Explorer, or command line (cmd.exe) and type or copy the following line


Usually this will start vscode if not already running and open settings.json.

In that file at the beginning add after the opening bracket

  "intelephense.environment.phpVersion": "7.4.0",

  ... rest of the existing settings.json file here

Before you change these files manually, it might be a good idea to make a backup of these files.

2023-01-19 23:01:13
This didn't work for me on Mac OS, but adding the below line to settings.json did: "php.validate.executablePath": "/usr/local/opt/php@8.0"

Since the above answers did not solve my problem, I'd like to give an additional solution that handled my issue of having the right PHP version in VS code. I got to this problem during installation of Laravel and the terminal in VS code was giving me the error that my platform is using PHP 7.4 and Laravel 9 requires PHP 8.0.2. It just caused me a headache to figure out where VS Code is taking the info that my platform is using PHP 7.4 (however my WAMP server was using PHP 8.2) (and I also set in VS code settings, according to the above answers, the following:

  1. "php.validate.executablePath": "C:/wamp64/bin/php/php8.2.0/php.exe"
  2. "intelephense.environment.phpVersion": "8.2.0",

But during creating a new Laravel project, VS code terminal still gave me the above error and did not recognize my PHP 8.2 version.

So my final working solution in Windows 11 (same in windows 10) was to setting the Path variable (to PHP executable) in Environment Variables.

1. in windows Start menu click and search for Environment Variables -> you can just open that control panel and click and open the Environment Variables settings:

enter image description here

2. You will get a new modal window and you have to click on Path in System variables like in the image below:

enter image description here

3. and you will find the PHP path and you have to just edit the path value to your own required PHP folder and then click OK. (I am not sure whether it is optional but I restarted my VS Code editor and everything was OK with PHP version from then on in VS Code regarding PHP version).

enter image description here

Code -> Preferences -> Settings

Look for "php version". Then change it