microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.96k stars 29.18k forks source link

PHP Validator Executable Path is broken completely. #62330

Closed GinoMan closed 5 years ago

GinoMan commented 6 years ago

Description of issue: When opening PHP files in VSCode, an error occurs with the php validator that says the following:

Cannot validate since is not a valid php executable. Use the setting 'php.validate.executablePath' to configure the PHP executable.

If you have not configured this value, the error reads:

Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.

I've attempted to diagnose the issue and have read several different webpages and even forums and I've discovered the following things:

  1. Whether the path includes spaces is irrelevant.
  2. Whether the path uses forward slashes or backslashes is irrelevant.
  3. Trying to eliminate spaces whether through symbolic linking, or copying the files to a folder in C: is irrelevant.
  4. Escaping spaces has no effect, it is irrelevant.
  5. It DOES NOT WORK AT ALL. Despite a PHP executable being exactly where the path is set to.
  6. It does not matter if the system path variable includes that php directory.
  7. It does not matter if you can happily run php from the commandline on any terminal.
  8. There is no setting that will make php validation work in Visual Studio code, despite the feature existing.

Steps to Reproduce:

  1. Install the latest PHP from php.net for windows, the threadsafe x64 version.
  2. If not done already, add the folder into which you installed php 7 to the system's path variable.
  3. Add the following lines to your vscode settings:

"php.suggest.basic": false, "php.validate.enable": true, "php.validate.run": "onType", "php.validate.executablePath": "<path.to.php>",

  1. replace with the absolute path of the php.exe file.
  2. start vscode, and open a PHP file.
  3. Note that you get a notification with one of the above errors.
  4. Change path every which way you know how to escape spaces in case that's the issue, or creating a spaceless symbolic link.
  5. Escape the backslashes by using doublebackslashes, get frustrated, and use forward slashes and even double forwardslashes. Then try removing ".exe", then try removing the drive letter.
  6. Try installing PHP somewhere else and setting the path there.
  7. Repeat step 7 and 8 in the new spaceless path that you've moved PHP to.
  8. Still incessantly get those errors and switch to another editor while whispering expletives and downing a shot of whiskey.
  9. Cry because VSCode is still better than the other editors.

Does this issue occur when all extensions are disabled?: I have no intention of disabling extensions since I need those to get to the php files on remote servers.

What extensions do you have installed?

Extension | Author (truncated) | Version better-comments | aar | 2.0.2 html-snippets | abu | 0.2.1 project-manager | ale | 9.0.1 vscode-json | and | 1.3.2 rc-beautify | Ato | 1.2.0 toml | be5 | 0.0.3 vscode-puppet | bit | 0.4.5 vscode-intelephense-client | bme | 0.8.8 pgformatter | bra | 1.5.1 rails | bun | 0.8.4 vscode-gemfile | bun | 0.0.2 better-toml | bun | 0.3.2 npm-intellisense | chr | 1.3.0 path-intellisense | chr | 1.4.2 gitignore | cod | 0.5.0 compulim-vscode-closetag | Com | 1.2.0 perl-toolbox | d97 | 1.3.0 dart-code | Dar | 2.19.0 vscode-markdownlint | Dav | 0.21.0 jshint | dba | 0.10.20 vscode-eslint | dba | 1.6.1 vscode-dash | dee | 2.0.0 git-extension-pack | don | 0.1.3 githistory | don | 0.4.3 javadebugger | don | 0.1.5 pgsql | dou | 0.1.3 drupal-8-snippets | dss | 0.0.2 vscode-rust-syntax | dun | 0.0.30 vscode-babel-coloring | dza | 0.0.4 gitlens | eam | 8.5.6 vscode-html-css | ecm | 0.2.0 tslint | eg2 | 1.0.40 vscode-npm-script | eg2 | 0.3.5 vscode-great-icons | emm | 2.1.44 json-tools | eri | 1.0.2 comment-anchors | Exo | 1.6.1 vscode-open-in-application | fab | 1.0.3 git-project-manager | fel | 1.7.1 php-debug | fel | 1.12.6 php-pack | fel | 1.0.2 auto-close-tag | for | 0.5.6 code-runner | for | 0.9.5 docker-explorer | for | 0.1.6 docker-extension-pack | for | 0.0.1 terminal | for | 0.0.10 vscode-mysql | for | 0.3.0 html-slim-scss-css-class-completion | gen | 1.1.1 open-in-editor-vscode | gen | 1.0.1 spacecadet | geo | 0.0.1 vscode-firefox-debug | hbe | 1.7.1 docker-linter | hen | 0.5.0 vscode-perl | hen | 1.17.0 beautify | Hoo | 1.4.7 ruby-linter | hoo | 1.0.0 rails-snippets | Hri | 1.0.8 pgsql-html | hub | 0.0.7 coldfusion | ili | 1.0.1 mysql-syntax | jak | 1.3.1 easy-icons | jam | 0.3.1 search-node-modules | jas | 1.3.0 shortcut-menu-bar | jer | 0.1.5 diff-tool | jin | 0.0.1 sublime-babel-vscode | jos | 0.2.10 puppet-vscode | jpo | 0.13.2 postgresql | JPT | 0.0.2 php-cs-fixer | jun | 0.1.89 vscode-rust | kal | 0.4.2 vscode-cfml | Kam | 0.4.1 node-module-intellisense | lei | 1.5.0 vs-color-picker | lih | 0.7.0 dart-import | lua | 0.1.0 VS-code-drupal | mar | 0.0.12 vscode-language-babel | mgm | 0.0.21 code-beautifier | mic | 2.1.0 dotenv | mik | 1.0.1 vscode-clang | mit | 0.2.3 vscode-remote-workspace | mkl | 0.37.0 rust-assist | moo | 0.2.2 perl-debug | mor | 0.4.1 hg | mrc | 1.2.3 vscode-apache | mrm | 1.1.1 vscode-scss | mrm | 0.6.2 python | ms- | 2018.9.2 cpptools | ms- | 0.20.0 csharp | ms- | 1.17.0 Go | ms- | 0.6.93 PowerShell | ms- | 1.9.0 sublime-keybindings | ms- | 4.0.0 debugger-for-chrome | msj | 4.10.2 debugger-for-edge | msj | 1.0.6 docker-compose | p1c | 0.3.0 cargo | pan | 0.2.0 vscode-docker | Pet | 0.3.1 ruby | reb | 0.20.0 live-sass | rit | 3.0.0 LiveServer | rit | 5.1.1 sass-indented | rob | 1.4.9 bash-debug | rog | 0.3.3 vscode-text-tables | Rom | 0.1.5 rust | rus | 0.4.10 vscode-workspace-switcher | sad | 1.9.0 RustyCode | sav | 0.19.1 vscode-sql-beautify | sen | 0.0.4 crates | ser | 0.3.5 bash-beautify | sha | 0.1.1 code-settings-sync | Sha | 3.2.0 vscode-table-formatter | shu | 1.2.1 slim | sia | 0.1.2 ColdFusion | Ske | 0.0.1 javascript-typescript | sou | 0.0.7 autoimport | ste | 1.5.3 vscode-docker-ws | tii | 0.1.0 pdf | tom | 0.3.0 vscode-docker-registry-explorer | Tqr | 0.1.3 terminal-tabs | Tyr | 0.2.0 vscode-lldb | vad | 1.0.0 cmake-tools | vec | 1.1.2 expand-selection-to-scope | vit | 0.2.0 vscode-react-native | vsm | 0.6.18 sublime-text-pack | wad | 0.0.2 city-lights-icon-vsc | Yum | 1.1.3 markdown-pdf | yza | 1.2.0 sublime-commands | Zar | 0.1.0 html-css-class-completion | Zig | 1.17.1 vsc-docker | Zim | 0.34.0 vscode-open-in-github | ziy | 1.3.6

What system are you on:

CPUs | Intel(R) Core(TM) i5-4460 CPU @ 3.20GHz (4 x 3193) GPU Status | 2d_canvas: enabledchecker_imaging: disabled_offflash_3d: enabledflash_stage3d: enabledflash_stage3d_baseline: enabledgpu_compositing: enabledmultiple_raster_threads: enabled_onnative_gpu_memory_buffers: disabled_softwarerasterization: enabledvideo_decode: enabledvideo_encode: enabledwebgl: enabledwebgl2: enabled Memory (System) | 11.92GB (1.38GB free) Process Argv |   Screen Reader | no VM | 0%

vscodebot[bot] commented 6 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

roblourens commented 6 years ago

Works for me, what is the path you set for php.validate.executablePath? What do you get if you paste that path into the command prompt and add --version?

The code here is very simple, it just spawns whatever you put in that setting and if the result is ENOENT, it shows that message.

Also, I recommend using a PHP extension for language support, since the builtin PHP support is extremely simple.

vchristi commented 5 years ago

I am a php beginner. I use Visual Studio and all files have been html. But now my developer changed to php files. I just need to alter text in the php files and then upload the corrected file to our website. If I edit a php in VS without having PHP installed, will the uploaded page operate incorrectly?

roblourens commented 5 years ago

Hi @vchristi please open a new issue next time. But you shouldn't have any problem.

vchristi commented 5 years ago

Thank you so much!

Sent from my iPhone

On Nov 6, 2018, at 5:18 PM, Rob Lourens notifications@github.com wrote:

Hi @vchristi please open a new issue next time. But you shouldn't have any problem.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

GinoMan commented 5 years ago

Works for me, what is the path you set for php.validate.executablePath? What do you get if you paste that path into the command prompt and add --version?

The code here is very simple, it just spawns whatever you put in that setting and if the result is ENOENT, it shows that message.

Also, I recommend using a PHP extension for language support, since the builtin PHP support is extremely simple.

If I paste that path, it gives me

PHP 7.2.8 (cli) (built: Jul 18 2018 10:03:03) ( ZTS MSVC15 (Visual C++ 2017) x64 )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

I should add that it included double-backslashes and still worked, I also tried with single backslashes and it worked. That's what's so confusing and infuriating.

What extensions would you recommend?

roblourens commented 5 years ago

I think https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-intellisense and https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client are the general favorites.

It might help narrow it down if you can try those and see whether they work.

vscodebot[bot] commented 5 years ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!