felixfbecker / vscode-php-intellisense

Advanced PHP IntelliSense for Visual Studio Code 🆚💬
MIT License
410 stars 88 forks source link

Error spawning PHP: Command failed: php --version #374

Open hariprasath-yadav opened 5 years ago

hariprasath-yadav commented 5 years ago

Error spawning PHP: Command failed: php --version

Above error shown in vscode as notifcation when i open Launch.json file is not creating automatically when i press F5 So i creating the file and code in it manually After created the launch.json, Debug is working properly I think because of the above error only the file is not creating and i can get the php version by using the command php -v

OS: Windows 10 VS Code Version: 1.28.0 Architecture: x64 PHP Version: PHP 7.1.8 XDebug Version: 2.5.5

felixfbecker commented 5 years ago

This extension is not a debugger.

Do you have the directory PHP is installed in added to your PATH? Can you post a screenshot of your PATH settings from control panel?

hariprasath-yadav commented 5 years ago

Yes i have added php path by using php -v i can get the php version at any location in my pc and this is my path

C:\Program Files (x86)\Ampps\php-7.1

felixfbecker commented 5 years ago

Well there must be a reason why it cannot spawn it: https://github.com/felixfbecker/vscode-php-intellisense/blob/0f9fecdf9832a8f6d88baf887d0c4e89d68bb379/src/extension.ts#L31

Do you have php.executablePath set in your settings?

hariprasath-yadav commented 5 years ago

Yes i have changed it the setting is

"php.validate.executablePath": "C:/Program Files (x86)/Ampps/php-7.1/php.exe",

felixfbecker commented 5 years ago

Thats php.validate.executablePath, not php.executablePath.

hariprasath-yadav commented 5 years ago

There is only four type of setting shown in vs code for the extension and they are

  1. php.suggest.basic
  2. php.validate.enable
  3. php.validate.executablePath
  4. php.validate.run

and the default value for the properties are

  1. "php.suggest.basic": true,
  2. "php.validate.enable": true,
  3. "php.validate.executablePath": null,
  4. "php.validate.run": "onSave"

and i have only made the change in 3rd property as

C:/Program Files (x86)/Ampps/php-7.1/php.exe

alessandronunes commented 5 years ago

I tried both:

"php.executablePath": "C:\Program Files(x86)\Ampps\php-7.1\php.exe", "php.validate.executablePath": "C:\Program Files(x86)\Ampps\php-7.1\php.exe"

Not working. Path is correct and into Windows system path.

benyaminl commented 5 years ago

Thats php.validate.executablePath, not php.executablePath.

@hariprasath-yadav Follow this, it's no shown on the settings but it's the Intelisense configuration.

benyaminl commented 5 years ago

@hariprasath-yadav @alessandronunes same PHP version? NTS or maybe TS version of PHP?

hariprasath-yadav commented 5 years ago

My php version in NTS Only

enriqueesmith commented 5 years ago

I tried both:

"php.executablePath": "C:\Program Files(x86)\Ampps\php-7.1\php.exe", "php.validate.executablePath": "C:\Program Files(x86)\Ampps\php-7.1\php.exe"

Not working. Path is correct and into Windows system path.

@alessandronunes Hello, I was having the exact same issue as you until I noticed that the path from the Windows system has the '\' symbol but I should I be using the '/' symbol. Once I changed the symbol to the '/' symbol, it worked!

From Windows, this path did not work: C:\tools\php73\php.exe

What I put in the settings.json file, which worked: "php.validate.enable": true, "php.validate.executablePath": "c:/tools/php73/php.exe", "php.validate.run": "onType", (Default here is "onSave" but I changed it)

I hope this helps.

d3ssen commented 4 years ago

I got this error and tried to do "php.exe --version" from the Windows cmd, it immediately showed a popup that I needed to install the Visual C++ Redistributable for Visual Studio 2015-2019. Once I did that the error didn't show up anymore.

/facepalm

CleitonCorrea commented 7 months ago

For me, it resolved by reversing the path of the PHP executable in vscode where it was C:\User\Path of PHP to C://User//Path until CS-FIXER is working fine heheh

image