soderlind / vscode-phpcbf

PHP Code Beautifier and Fixer for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=persoderlind.vscode-phpcbf
GNU General Public License v3.0
28 stars 10 forks source link

Still not found: executablePath (when phpcs and phpcbf installed via Composer) #42

Closed dgwyer closed 3 years ago

dgwyer commented 3 years ago

I've tried all the suggestions here, but none seems to work: https://github.com/soderlind/vscode-phpcbf/issues/1

I'm on Windows 10, and am using Git Bash as the terminal, and still getting the PHPCBF: spawn phpcbf ENOENT. executablePath not found. error.

FYI - I'm also using this VS Code extension and that finds the "phpcs.executablePath": "./vendor/bin/phpcs" path with no issues at all, which is interesting: https://marketplace.visualstudio.com/items?itemName=ikappas.phpcs

Here's my .vscode/settings.json file:

{
  "settings-key": {
    "phpcs.enable": true,
    "phpcs.executablePath": "./vendor/bin/phpcs",
    "phpcs.standard": "WordPress",
    "phpcbf.enable": true,
    "phpcbf.documentFormattingProvider": true,
    "phpcbf.onsave": true,
    "phpcbf.executablePath": "./vendor/squizlabs/php_codesniffer/bin/phpcbf",
    "phpcbf.standard": "WordPress"
  }
}
danieliser commented 3 years ago

@dgwyer - Curious why they are nested inside settings-key. A settings.json file in this context should all be top level settings like

{
  "phpcs.enable": true,
  "phpcs.executablePath": "./vendor/bin/phpcs",
  "phpcs.standard": "WordPress",
  "phpcbf.enable": true,
  "phpcbf.documentFormattingProvider": true,
  "phpcbf.onsave": true,
  "phpcbf.executablePath": "./vendor/squizlabs/php_codesniffer/bin/phpcbf",
  "phpcbf.standard": "WordPress"
}

Unless settings-key here is [php] or similar context limiter.

Curious if you have tried using WSL instead? Much better in most cases.

dgwyer commented 3 years ago

WSL?

danieliser commented 3 years ago

@dgwyer Windows Subsytem for Linux (WSL) is a true Linux kernal living right inside your Windows OS.

Install any flavor of nix like Ubuntu, create multiple instances etc.

VS Code will even run right inside the WSL Ubuntu Instance for a native command line experience.

That is to say, you put your project inside the WSL VM (via windows explorer if you can believe it).

Then work entirely inside the VM essentially.

All this is to say, developing on Windows with WSL is 99% the same as developing on a bare metal linux machine with the command line, file browser integration, automated localhost host/port mapping & VS Code support Windows has done well to build a better dev experience.

I very rarely have to leave the WSL environment, with the rare Python I/O issue when interacting with hardware directly.

Pretty versatile.

dgwyer commented 3 years ago

I can't remember the reason for using "settings-key" tbh. I'm using another extension now anyway.