PHPCS setup in Visual studio code

Husna picture Husna · Aug 29, 2018 · Viewed 10.3k times · Source

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?

Answer

Husna picture Husna · Aug 30, 2018

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.