'Visual Studio Code not recognize the term "php" as a command

In my Windows terminal (cmd), the php -v command return the version of installed PHP in my computer. But when I type it at Visual Studio Code (version 1.63.2) terminal, it gives me the error below:

php : The term 'php' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • php -v
  • + CategoryInfo          : ObjectNotFound: (php:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    

Note that the environment variable is already set. Any idea please ?



Solution 1:[1]

VSC is running powershell as terminal, configure it to use CMD in your user's file->preferences->settings add:

"terminal.integrated.shell.windows":"cmd.exe"

Solution 2:[2]

Actually, I solved the problem by deleting (killing) the already created profile in the VSC terminal (see the below figure) and adding a new one. Restarting VSC is not enough. You have to delete or kill the terminal profile and re-create it again by choosing PowerShell or command prompt or whatever you want according to your system.

Delete profile

enter image description here

Create profile

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DDS
Solution 2 stic-lab