ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

phpcs: Unable to locate phpcs. local composer install (Windows 10) #175

Open helgatheviking opened 4 years ago

helgatheviking commented 4 years ago

Like a lot of other people, I'm running in to the error where the plugin cannot find the path to phpcs.

The instructions say that you can do a Project-wide Installation by using composer to require -dev squizlabs/php_codesniffer

The settings for phpcs.executablePath say that you can leave it blank and it will find the file from your composer.json.

If omitted, the plugin will try to locate the path parsing your composer configuration or the global path.

But the plugin cannot seem to find that installation and to use it for linting.

phpcs: Unable to locate phpcs. Command failed: "c:\Users\helga\Local Sites\testsite\app\public\wp-content\plugins\charitable-recurring" --version '"c:\Users\helga\Local Sites\testsite\app\public\wp-content\plugins\charitable-recurring"' is not recognized as an internal or external command, operable program or batch file.

Where "charitable-recurring" is the project's root folder.

So I tried inputting the relative path as vendor\squizlabs\php_codesniffer\bin\phpcs.bat

and that at least changes the error. But "An error occurred" doesn't tell me anything.

PHP-CS-Fixer: An error occurred.

Has anyone gotten this work with a local-project installed version?

ryentzer commented 4 years ago

Have you tried to put in an absolute path? That was the only way I was able to get it to work on my mac.

For instance, in my settings.json I have this:

{ "phpcs.executablePath": "./vendor/bin/phpcs", "phpcs.standard": "./vendor/wptrt/WPThemeReview" }

where vendor is a folder with composer and php related files.