Setup PHP CodeSniffer along with WordPress Coding Standards [ Windows, XAMPP ]

The other day, I had some problem setting up latest WordPress coding standard for PHP CodeSniffer on a Windows machine. It was throwing some errors/warnings like the below. There were some others, but eventually we had fixed some of those. However the WP coding standards were not getting listed in phpcs. 🙁

Here are the steps to fix the problems and setup PHP CodeSniffer along with WordPress Coding Standards namely WordPress, WordPress-Core, WordPress-Extra and WordPress-VIP. FYI, I am on a Windows 7 box with XAMPP setup for Apache, MySql & PHP.

Image: Flicker

Image: Flicker cc

Install PHP CodeSniffer on Windows through PEAR installer:
Uninstall the old CodeSniffer(if any):

Install the latest CodeSniffer using PEAR:

It failed, that means we need to clear the cache:

Again, try installing the latest version of the PHP_CodeSniffer package:

Update the channel as asked above:

Upgrade pear too. Incase if any things are old.

Do a cache clear again:

See the list of default coding standards in PHP CodeSniffer:


Install WordPress coding standard definitions for the CodeSniffer:
Navigate to the coding standards directory:

Fetch the WordPress coding standards into CodeSniffer’s standards directory. (if git command not working on your command prompt, you may use any gui for git clone)

As, all of the individual standards of WordPress namely WordPress, WordPress-Core, WordPress-Extra and WordPress-VIP are in one directory, for phpcs to be able to detect the standards we need to add the path to phpcs’s installed_paths.

Check if all the installed standards are listed now:


How to use PHP_CodeSniffer:
You can use command prompt to check your code, or you can also configure the same with different IDEs like NetBeans, PHPStrom etc.

You can write the output of code sniffer to a file:


  1. Hey thanks a lot for this tutorial. I was also facing this issue had no clue about how to solve it. After reading your tutorial it was easy for me to setup php codesniffer along wordpress coding standards.

  2. I just ran through this tutorial and all was good until I run phpcs -i following this line phpcs –config-set installed_paths c:\xampp\php\pear\PHP\CodeSniffer\Standards\WordPress-Coding-Standards. At which point I get this error

    Any suggestions?


Leave a Reply