How to setup WPCS with Visual Studio Code

Step 1: Install PHP
Composer requires PHP 5.3 or higher… to install PHP (7.2) on Ubuntu, run the commands below

Step 2: Install Composer

Now that PHP is installed… you can now run the commands below to install Composer

The commands above will download Composer from its maintainer page and install it into the /usr/local/bin directory… this is a local global directory for application executables…

All settings correct for using Composer Downloading... Composer (version 1.6.4) successfully installed to: /usr/local/bin/composer Use it: php /usr/local/bin/composer

Now simply run the commands below to test whether Composer is installed.

The output should look like something below

[email protected]:~$ composer ______ / ____/___ ____ ___ ____ ____ ________ _____ / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/ / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ / \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/ /_/ Composer version 1.6.4 2018-04-13 12:04:24 Usage: command [options] [arguments] Options: -h, --help Display this help message -q, --quiet Do not output any message -V, --version Display this application version --ansi Force ANSI output --no-ansi Disable ANSI output -n, --no-interaction Do not ask any interactive question --profile Display timing and memory usage information --no-plugins Whether to disable plugins. -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory. -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Step 3: Install PHP_CodeSniffer with Composer

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

If installation completed rune this comment to test phpcs -i
not working this comment? You need to dow create symbolic link

Step 4: Install the WordPress Coding Standards Sniffs
First go to /usr/local/bin/

Configure phpcs to use the WordPress Coding Standards sniffs

To verify you’ve configured phpcs correctly, run phpcs -i . You should see the following:

The installed coding standards are PSR12, Squiz, Zend, PSR2, MySource, PSR1, PEAR, WordPress, WordPress-Docs, WordPress-Core and WordPress-Extra

Step 5:

Add this code in VSC settings.

and install VS Code extension WordPress VS Code Extension Pack