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.
- Step 1 - Download it.
- Install it, the instructions are on the download page.
- Make it globally accessible in your PATH.
- In your System Environment Variables make sure Composer is in your PATH.
- i.e. C:\ProgramData\ComposerSetup\bin;
PHP 7 and save to C:\php7
Using Git Bash:
#Download the go-pear using CURL
curl -OL http://pear.php.net/go-pear.phar
Now open Windows Command Prompt as an Administrator
As it states at the end of the install instruction, install Reg edits.
pear install PHP_CodeSniffer
Close all Command Prompts and open a new one with Admin Rights
composer global require "squizlabs/php_codesniffer=*"
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.
The language server needs at least PHP 7 installed. Version found:
Add C:\php7 to System Environment PATH
File->Preferences->Settings->Add "php.validate.executablePath": "C:\\php7\\php.exe"
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.
;extension_dir = "ext"
extension_dir = "ext"