Husna
Husna

Reputation: 1386

PHPCS setup in Visual studio code

I want to add phpcs CodeSniffer in VScode. I'm getting an error phpcs: Request workspace/configuration failed with message: Unable to locate phpcs. Please add phpcs to your global path or use composer dependency manager to install it in your project locally. in visual studio. I installed PHPCS and PEAR also. these code I tried in user-setting and workspace settings also "phpcs.composerJsonPath": "C:/wamp/wpcs/composer.json" in VScode. But didn't get where and how should I set the path? my path directory is C:\wamp\wpcs\phpcs. Can anyone suggest me how to do?

Upvotes: 4

Views: 14503

Answers (1)

Husna
Husna

Reputation: 1386

Finally, I got the answer. First, I added extensions phpcs and wpcs in VScode then in the user-settings I have added these arguments make sure PEAR and PHPCS, WPCS are installed in the local directory.

{
"phpcs.standard": "WordPress",
"phpcs.enable": true,
"php.validate.executablePath": "C:/wamp/bin/php/php5.6.25",
"phpcs.executablePath": "C:/wamp/bin/php/php5.6.25/phpcs.bat",
"phpcs.autoConfigSearch": true
}

After setup everything now its working fine.

Upvotes: 3

Related Questions