How to add PHPCS checking to Visual Studio Code

black flat screen computer monitor

If you’re rocking VS Code and would like to automate PHPCS checking from within the editor, look no further.

Not installed PHPCS yet? Check out my guide first. Once that’s done, thankfully, the process to do this is quite simple…

  1. Click the Extensions icon in the left sidebar (or head into the toolbar and find it) and search for phpcs. At the time of writing this there were 2 available, but one was deprecated due to it not being maintained – you need the other one.
  2. Install the extension.
  3. Open up Command Palette and search for Preferences: Open User Settings (JSON)
  4. This will open up settings.json and show any existing user settings.
  5. Add the following setting between the open and close braces…

    "phpcs.standard": "{your standard(s)}",

    If this is added after the final settings, make sure the penultimate one has a comma at the end.

    {your standard(s)} is the name of your standard, or standards.

    So my total file looks like this…
    "workbench.colorTheme": "Default Dark Modern",
    "php.validate.executablePath": "",
    "phpcs.standard": "WordPress-Extra,WordPress-Docs,WordPress-VIP-Go",
  1. A full list of PHPCS parameters can be found on the extensions page and these can be added in the above config file.

And that’s it. To view your PHPCS output, make sure to open the Debug Console with the PROBLEMS tab active.

(Mentioned on WPBriefs)

Talk to me!

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: