-
Notifications
You must be signed in to change notification settings - Fork 27.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot validate the php file. #251
Comments
Just read what it says: "Use the 'php.validate.executablePath' setting to configure the location of 'php'" Language - PHPVS Code is now using the official PHP linter (php -l) for PHP language diagnostics. VS Code will now stay current with PHP linter improvements. There are two new settings to control the PHP linter:
|
This is how I solved it on Windows 7: Mind the forward slashes. |
The |
kc9eye, DerTolleEmil - Thank you very much, you cool. |
kc9eye, Thank you |
@kc9eye is right, set "php.validate.executablePath" : "DiskName:/{folder php unzipped to}/php.exe", String 'php.exe' is required, but php7 is not required. |
is this important? Do I need to fix that issue to properly use PHP on Code? I'm just using it with XAMPP and it seems to work. |
You will not get any red squiggly lines if you have errors in your code if you do not have the php executable set. You will still get syntax highlight and autocomplete information but if you are missing say a semicolon the editor will not tell you so; You will only notice the error when you actually run the code. I haven't used XAMPP in quite a while but if I remember correctly XAMPP has the php binary included, probably in C:\xampp\php\php.exe (if you have it installed there). Might also be C:\xampp\bin\php\php.exe or C:\xampp\bin\php\php-5.x.x\php.exe I'm sure you'll be able to find it and it is highly recommended that you do set the value, it will make your life a lot easier if you get syntax errors highlighted when editing your files. |
Thanks. Just done it. |
Thanks File > Preferences > Workspace Settings and added in settings.json |
And if you are using xampp, then follow the snippet shared by @boloindia above and just change the path too: "D:/xampp/php/php.exe" This will work as I have done it the same way. |
I spent 20 minutes on this error) |
Thank you. I am using xampp, it works by overwrite the default setting of php.validate.executablePath with "D:/xampp/php/php.exe". |
Changing the to front slash works Fine |
On Linux use whereis in bash: |
How configure php.validate.executablePath for docker container? |
It not getting saved. unable to edit preferences |
What is the error you are getting Run with Root it will work fine. |
I need to add php path for validation. I have to add path to C:\xampp\php\php.exe but its not getting edited in user settings under preferences |
@SHarieprasadh when you open the workspace setting file, VS opens an empty settings.json file. Add the following code as show below (change "C:/xampp/php/php.exe" to your php.exe location)
|
Still doesn't work in the current version. Tried both and even downloaded the most recent version of php, and referred to that folder as well but restarting, clicking on the php file, it still claims it can't find php. I can copy and paste it in my command line and it runs php: D:/php/php.exe, but visual studio code refuses to acknowledge it is there. Changed it in both the settings file it pops up with the error, and File->Preferences-> workspace settings, but makes no difference- won't acknowledge it's there. Even tried reinstalling Visual code, no change. About an hour of that, and switching to Atom. (After switching to atom, it told me that it wanted a newer version of php. I upgraded xampp to the last listed version/ newest, and Atom was fine. Reinstalled VS code, and VS code finally worked. So VS Code reports 'can't find php' when it really means 'the php version found is older than expected') |
For WampServer PHP v7 : PHP v5.6 : Also refer @boloindia for settings |
@doomtoo having same issues on Windows 10 here. :( Tried everything, but it still won't work. Currently I've set it to Perhaps VSCode doesn't like the D: disk? |
I have tried every combination and it still won't work with the php.validate.executablePath. It only works if you add the PHP folder path to your PATH. |
I get the same error - cannot get it to acknowledge PHP. Addng both these seems to have fixed it: |
This is an example with Wamp64
|
Still not working for me and also for others |
No offense but are you sure you should be tackling code if you don't even understand simple file paths and config files? The syntax is: "php.validate.executablePath": "C:/php/php.exe" "php.executablePath" (as mentioned earlier) does not exist (according to autocomplete) and does not have to be set. You can use either standard forward slashes as the path separator ("C:/php/php.exe") or double blackslashes ("C:\\php\\php.exe"), both are correct. Here is a complete settings.json from my installation:
If you have no idea where your php.exe file is, open a command prompt and paste the following code:
Replace C:\ with D:\ or any other drive if you have PHP installed somewhere else. It will output lines like
if you have PHP installed multiple times you will get multiple results, pick the one you want and put it into your config file. Remember to either replace the backslashes with two backslashes or replace them with a forward slash. |
No offense? It didn't work for me without "php.executablePath": "C://xampp//php//php.exe" |
The no offense wasn't aimed at you. And I know that it sounds incredibly passive aggressive, which isn't my point (if it was I wouldn't have posted any other details). It's just that people are probably a few steps ahead of themselves when learning to code if they can't even get the editor running (although admittedly if I still was a beginner a json config file would throw me off quite a bit as well). Anyway: Would you mind posting your entire config file? I just searched through the source code, there is not a single mention of any "php.executablePath" setting. The amount of additional forward slashes shouldn't matter either as they are ignored anyway. I'd like to see what happens on my installation using your config file. Do you know if you have the path of your PHP installation set in your PATH environment variable as well? |
The only way I could get php linting to work properly was by doing exactly what creatace said -- set both php.validate.executablePath AND php.executablePath like below (on Win10, brand new machine).
|
Sadly I can't carry on with VS code until PHP support moves on - I need old style self-defined function hinting with 'go to' / show definition. Why do people think functions are dead and they only need to support classes etc. ? |
Lol @ someone saying people shouldn't try coding if the IDE doesn't work XD
There's a surprising amount of broken stuff out there. It depends which
build you get a lot of the time, whether it worked for you, and didn't work
for someone else.
Many times I've spent more time getting the IDE to work properly than
actually coding my first program, since the documentation can be outright
broken, missing, wrong, or out of synch with the current version.
It's like saying "just because a car doesn't have wheels, should you ever
try driving again"? If the car doesn't have wheels, it's not the drivers
fault they can't start learning to drive XD
It took me a day of trying various solutions before one worked (for getting
it to find the PHP version installed), and I've worked in PHP for years,
Java for years, C++, ect.
Luck with getting an IDE working on initial setup != coding skills.
(NOTE: for me, it wouldn't work because it didn't like the PHP version I
had installed. Xampp comes with 5.6.3 by default- probably think it's more
common/stable. You have to go to other downloads, and choose the last one
listed / PHP 7.1.1, and only then would visual studio code acknowledge it.
The program tells you it can't find it, even if it can, because it's
expecting a certain version. Not very well designed user feedback. Or go
ahead and blame it on the user following the tutorials for the first time
XD)
…On Wed, Apr 26, 2017 at 7:14 AM, cretace ***@***.***> wrote:
Sadly I can't carry on with VS code until PHP support moves on - I need
old style self-defined function hinting with 'go to' / show definition. Why
do people think functions are dead and they only need to support classes
etc. ?
I also need mixed PHP-HTML highlighting and completions
The search continues.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#251 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAr25dlL0E0rlU_JblnIirkA9FOsaV-Iks5rz1EpgaJpZM4GloRk>
.
|
Re. the PHP 7 requirement: |
hi, |
Some notes:
|
Hi, how can I solve this same problem, using bitnami lamp. "php.validate.executablePath": "/home/myname/lampstack-7.1.4-0/php/bin", Thanks. |
@bobdonkey |
Ubuntu 17.04 Xampp VS Code Settings "php.validate.executablePath": "/opt/lampp/bin/php", |
Still not working Can any one make a video and share us ? |
For Xamp , "php.validate.executablePath": "C://xampp//php//php.exe" |
On Windows 10, VS Code 1.14.2 with WAMPServer, the following settings worked for me. Note that you should search for the actual path to your local php.exe: File > Preferences > Settings > search for php. Mouse over the settings then click edit.
"onType" gets you validation as you type. If you don't set that, it looks like validation is still not working. Not sure why the default would be onSave but once you see it's running OK you can set this however you like. |
On Windows the issue can be resolved by adding your php location to the Window System Environment variable known as the Path variable. This is a list of paths that are checked. |
My configuration is below, and its working!! Windows 10 + Visual Studio Code 1.16.1 + xampp 7.0.23 |
Hey ! WINDOWS 10 - VAGRANT |
No matter what I set php.validate.executablePath to, I could not get it working. Tried forward and backwards slashes as well as leaving out/including php.exe. The only thing that worked for me was adding the php directory C:\php7 to the PATH variable in Windows. |
I do not know how to fix this error - Cannot validate the php file. The php program was not found. Use the 'php.validate.executablePath' setting to configure the location of 'php'
The text was updated successfully, but these errors were encountered: