How to install PHP CodeSniffer for 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.

To install PHP CodeSniffer:

  1. install PHP CodeSniffer:
  2. next, install the WordPress PHP CodeSniffer rules here:

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 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 VIP coding standard. When working on an existing codebase we expect the code to pass the VIP minimum standard but strongly encourage you to follow the VIP standards.

Should you wish to run both standards ( VIP minimum standard & VIP coding standard), you can add both to PHPCS by running the following configuration command:

phpcs --config-set installed_paths [/path/to/standard],[path/to/standard]

(note the comma separating each standard)

Ready to get started?

Tell us about your needs

Let us lead the way. We’ll help you select a top tier development partner. We’ll train your developers, operations, infrastructure, and editorial teams. We’ll coarchitect your deployment processes. We will provide live support for peak events. We’ll help your people avoid dark alleys and blind corners, and reduce wasted cycles.