WPCS with Visual Studio Code


The easiest way to get started with PHP_CodeSniffer is to download the Phar files for each of the commands:

# Or download using wget
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar

# Then test the downloaded PHARs
php phpcs.phar -h
php phpcbf.phar -h


If you use Composer, you can install PHP_CodeSniffer system-wide with the following command:

Make sure you have the composer bin dir in your PATH. The default value is 

, but you can check the value that you need to use by running 


Or alternatively, include a dependency for 

 in your 

 file. For example:

You will then be able to run PHP_CodeSniffer from the vendor bin directory:

Install the WCPS:


After setting the WPCS well, if we want to format the code with shortcut key according to WordPress coding standard, we’ll need to follow the instruction below –

  1. Install the PHPCBF extension.
  2. Set the phpcbf executable path.
  3. Set the shortcut key.My user settings are like –


    In need visit –  https://github.com/tommcfarlin/phpcs-wpcs-vscode https://wpbeaches.com/set-up-composer-and-phpcodesniffer-on-visual-studio-code-on-macos/