Installing Multiple Coding Standards There's an interesting challenge that comes if you want to configure multiple coding standards with PHPCS.

I’ve talked about the importance of using coding standards (whatever standard you opt to use it up to you) and how to get PHP CodeSniffer (especially with Visual Studio Code) set up in several posts.

But there’s an interesting challenge that comes if you want to configure multiple coding standards with PHPCS. And this isn’t that strange a scenario, either.

Imagine you have several different projects on which you’re working – one uses WordPress’ coding standards, one uses PSR2, and one uses some other set of rules defined by the organization for which you work.

And you want to add them all as options to your configuration.

Multiple Coding Standards

To do this, I’m assuming you have the rules all set in their directories. For example, I have rule sets located in two different directories in my Projects directory (which is located in Sync).

  1. ~/Sync/Projects/wpcs
  2. ~/Sync/Projects/WDS-Coding-Standards

And have PSR2 installed, too.

Here’s the thing: At first, it would seem that the easiest thing to do for adding multiple sets of rules at the same time would look like this:

Even if your shell’s environmental variables are considered correctly, this doesn’t necessarily hold. Instead, it will work for the duration of the shell session, but it won’t hold the next time you open your IDE, your terminal, or the integrated terminal in your IDE it likely won’t hold.

So what do we do?

Easy: When you’re setting the paths to your rules, make sure to use the fully qualified path:

And that does it. Assuming the environmental variables are properly set and you’ve specified the proper paths to your coding standards, then you should be good to go.