Making PHP Code Sniffer plugin work in Sublime Text 3

I’ve installed php Code Sniffer Sublime Text 3 plugin today and, aside for the installation of accessory tools the plugin will need to work its over-zealous finger-pointing-at-bad-code magic I’ve run into a problem about its setting I’ve never run into before for any other Sublime Text plugin.

Easy part

Installing the plugin itself can be done via Package Control searching for “Phpcs”.
After that a little OS fiddling will be required to install

  1. PHP Code Sniffer
  2. PHP Mess Detector
  3. eventually PHP Coding Standards Fixer

and I will gladly leave that part behind. It’s trivial anyway.


After all that is done launching the PHP Code Sniffer: sniff this file command will be of no visible effect. Simply put the plugin needs to know the paths to launch the just installed CLI tools.
As detailed the plugin site some configuration is required. After browsing Sublime Text bar [caption id=“attachment_527” align=“aligncenter” width=“1024”]Phpcs settings Phpcs settings[/caption] I end up with the plugin configuration file but it seems like I can’t edit it. [caption id=“attachment_528” align=“aligncenter” width=“1024”]Missing file… Missing file…[/caption]

Easy fix

The fix is as easy as simply creating the missing Phpcs folder and trying to edit the file again.

$ mkdir ~/Library/Application\ Support/Sublime\ Text\ 3/Packages/Phpcs

This time editing the settings file will work, having an actual real place to write its contents, and launching PHP Code Sniffer: sniff this file will light your .php file like a Christmas tree pointing out all your frowned-upon coding practices. [caption id=“attachment_529” align=“aligncenter” width=“1024”]Unpolite finger-pointing I hate it.[/caption]