Vscode: PHP 7 executable not found

Created on 14 Nov 2016  路  18Comments  路  Source: microsoft/vscode

  • VSCode Version: 1.7.1
  • OS Version: Windows 10 Pro N (Version 10.0.14393 Build 14393)

Steps to Reproduce:

  1. open vscode
  2. open .php file
  3. even though php 7.0.10 is freshly installed, error about missing executable is shown

Additional info:

  1. wamp server 3.0.6 installed
  2. php 7.0.10 installed (delivered with above)

I've been working with vscode for some time now, and ever since I started, I had php 7 executable set and everything was working. Lately (it might be updates' fault) I got this 'php 7 not installed' error.

Error itself: 'PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting'.

My php-related preferences:

`...
"php.validate.executablePath": "C:\wamp64\bin\php\php7.0.10\php.exe",

"php.validate.run": "onType",
...`

I tried messing with slashes: '/', '//', '\', '\' - nothing seems to work.
I also tried to set php 5.6.25 as executable path, but I guess it's php7 only.
I tried to turn off validating php with:
"php.validate.enable": false
but that didn't work for me either.
I run php.exe and code.exe as admin.

bug needs more info php

Most helpful comment

@kacperknapik Follow these steps on Windows 10:

  1. Right click on the start menu.
  2. Click on System.
  3. At the left you will find Advanced system settings click on it and then go to the Advanced tab.
  4. At the bottom click on Environment Variables.
  5. At the first section where the label reads "User variables for _YourName_" click on New; otherwise, if you already have the variable defined for your user select it and click Edit.

If you clicked New it should look like this:

Variable name: PATH
Variable value: C:\wamp64\bin\php\php7.0.10

If you clicked Edit then it may have more paths in it beyond VSCode's path so this might look like this:

Variable name: PATH
Variable value: C:\Program Files\nodejs;c:\Program Files\Java\jdk1.8.0_92\bin;C:\wamp64\bin\php\php7.0.10

Notice that I've added your path to the end of the variable's value.

note: When there's more than one path the UI shows all the paths in a list to see the _raw_ value you can use Edit Text.

  1. After this modification you should no longer see the error.

Finally just for completeness if you comfortable with the command line you can do something like this:

setx PATH "C:\wamp64\bin\php\php7.0.10"

warning: If you have an existing paths in PATH this will erase everything and replace it with the value C:\wamp64\bin\php\php7.0.10.

I hope it helps.

All 18 comments

I tried to set it in the settings and it never worked for me too, finally to make it work I had to add it to the PATH.

p.s. Some people might not understand what PATH means so it might be useful to modify the error message to something like "PHP executable not found. Install PHP 7 and add it to your PATH at the environment variables or set the php.executablePath setting"

@eyalsk tell me more about this PATH adding
@aeschli keep me informed about this bug-ish situation

@kacperknapik Follow these steps on Windows 10:

  1. Right click on the start menu.
  2. Click on System.
  3. At the left you will find Advanced system settings click on it and then go to the Advanced tab.
  4. At the bottom click on Environment Variables.
  5. At the first section where the label reads "User variables for _YourName_" click on New; otherwise, if you already have the variable defined for your user select it and click Edit.

If you clicked New it should look like this:

Variable name: PATH
Variable value: C:\wamp64\bin\php\php7.0.10

If you clicked Edit then it may have more paths in it beyond VSCode's path so this might look like this:

Variable name: PATH
Variable value: C:\Program Files\nodejs;c:\Program Files\Java\jdk1.8.0_92\bin;C:\wamp64\bin\php\php7.0.10

Notice that I've added your path to the end of the variable's value.

note: When there's more than one path the UI shows all the paths in a list to see the _raw_ value you can use Edit Text.

  1. After this modification you should no longer see the error.

Finally just for completeness if you comfortable with the command line you can do something like this:

setx PATH "C:\wamp64\bin\php\php7.0.10"

warning: If you have an existing paths in PATH this will erase everything and replace it with the value C:\wamp64\bin\php\php7.0.10.

I hope it helps.

@eyalsk this really worked. I think that's a great workaround for vscode's executable path error.

Thanks!

@dbaeumer I will wait for more info

@kacperknapik You welcome, I glad it worked. :)

Just to clarify it isn't really a _workaround_, the message you get try to tell you to do exactly that in the highlighted part "PHP executable not found. Install PHP 7 and add it to your PATH or set the php.executablePath setting" but it isn't as clear as it should be, however, setting it in the VSCode's settings should work just as well as setting it in the PATH and unfortunately it doesn't.

The only explanation I have for this is that the wamp64 php.exe isn't self contain (e.g load a dll or starts another exe). In this case setting php.executablePath will not work. Need to thing if I should tweak the PATH when I start the executable.

@dbaeumer I didn't download WAMP or use it and I encountered the same problem, I've downloaded PHP7 from the official website, put it at c:\Program Files\Php\70\, configured IIS, everything runs perfectly fine and when I tried to configure VSCode and set the location to the PHP executable it failed with the exact same error above so it isn't strictly related to WAMP.

@eyalsk thanks for the info.

@dbaeumer You welcome.

For anyone else who comes across this thread... there are multiple very similar-looking errors that could be produced and have been known to cause confusion, so I included a full run down of potential failure modes and resolution steps here: https://github.com/Microsoft/vscode/issues/13356#issuecomment-252541241

@mousetraps thanks for doing this!

I just tried it with php 7.0.14 and it works for me. We keep checking

Works if the path as even a blank in it :-) (c:\Program Files\Php\70\)

One thing to note: the path must include the php.exe itself. So the setting must look like this: "php.validate.executablePath": "C:/apps/php 7.0.14/php.exe"

Using php from wamp works for me as well:

"php.validate.executablePath": "C:/apps/wamp64/bin/php/php7.0.10/php.exe"

capture

Can someone provide me with a test workspace (best with php included) that demonstrates the behavior?

This issue has been closed automatically because it needs more information and has not had recent activity. Please refer to our guidelines for filing issues. Thank you for your contributions.

Facing the same error. Freshly installed today. but getting error on opneing the VSCODE

I had the same problem with VSCODE not recognizing PHP 7.1.9. So, I tried Eclipse, and it doesn't like 7.1.9 either. However, I had Eclipse scan xampp/php 5.6.31 and it recognized php-cgi.exe and php.exe, but ignored php-win.exe. Other than the obvious difference in php level, the outstanding difference between the two is xampp/php has a pre-configured php.ini.

Simply
goto vsCode user settings and inside curly braces ...
{
// The path to a PHP 7+ executable.
"php.executablePath": "E:/xampp/php/php.exe",
}

Note: Point to _XAMPP or WAMP or PHP_ executable file (php.exe). _Restart VSCode_ . That's it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vsccarl picture vsccarl  路  3Comments

philipgiuliani picture philipgiuliani  路  3Comments

lukehoban picture lukehoban  路  3Comments

sijad picture sijad  路  3Comments

omidgolparvar picture omidgolparvar  路  3Comments