Documentation How to install PHP CodeSniffer for WordPress.com VIP

How to install PHP CodeSniffer for WordPress.com VIP

Did you know that you could get much of the feedback given by the VIP team shown to you in real-time, as you code?

PHP CodeSniffer (aka PHPCS) is a tool that will help you write VIP approved code by ensuring it meets VIP coding standard. Many IDEs and text editors (e.g. PHPStorm, Sublime Text, Atom and Vim) have packages which will highlight any code which departs from VIP coding standards, or which has security or performance issues. Running this tool in your development environment or code editor allows you to fix the errors as you code, helping you develop to VIP best practices.

The first step is to install PHP CodeSniffer inside your IDE or text editor.

First start by installing PHP CodeSniffer: https://github.com/squizlabs/PHP_CodeSniffer#installation

Then proceed with installing the WordPress PHP CodeSniffer rules here: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#installation

When working on an existing codebase or when the WordPress coding standard does not match your team’s coding standards, you can take advantage of using the WordPress.com VIP Minimum standard for PHPCS which is also being used for automated code scanning in the Deploy Queue.

You can then integrate PHP CodeSniffer inside your favourite IDE, we have examples for a few popular ones:

It’s also possible to run PHP CodeSniffer in your Continuous Integration build process, e.g. via Travis or Circle CI, which allows you to see issues reported against any pull requests and to receive reports of issues via email and other channels. If you’d like us to configure the rules to run on your VIP Go GitHub repository, then please let us know and we’ll be happy to set this up for you.

When submitting your code to VIP for the initial theme we expect the code to not trigger any PHP CodeSniffer blockers and as few warnings as possible. We also expect it to pass the WordPress.com VIP coding standard. When working on an existing codebase we expect the code to pass the WordPress.com VIP minimum standard but strongly encourage you to follow the WordPress.com VIP standards.

Documentation is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.