A Blog Of Random Coding Techniques & Experiments Robert Askam

How to install phpcs in Visual Studio Code on Windows 10 also remove the error phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer dependency manager to install it in your project locally.

PEAR

As it states at the end of the install instruction, install Reg edits.

PHP Codesniffer

pear install PHP_CodeSniffer

PHPCS

Close all Command Prompts and open a new one with Admin Rights

composer global require "squizlabs/php_codesniffer=*"
phpcs --version

Visual Studio Code

Restart your Visual Studio Code and you should now not get the error:
phpcs: Unable to locate phpcs. Please add phpcs to your global path or use composer dependency manager to install it in your project locally.
Find a PHP file and incorrectly format it and it should now alert you.

Notes

Issue:
The language server needs at least PHP 7 installed. Version found: Fix:
Add C:\php7 to System Environment PATH
File->Preferences->Settings->Add "php.validate.executablePath": "C:\\php7\\php.exe"Issue:
The openssl extension is required for SSL/TLS protection but is not available. If you can not enable the openssl extension, you can disable this error, at your own risk, by setting the 'disable-tls' option to true.Fix:
Open php.ini