Making PHP Code Sniffer plugin work in Sublime Text 3
January 24, 2014
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
and I will gladly leave that part behind. It's trivial anyway.
Uh?
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"][](http://theaveragedev.local/wordpress/wp-content/uploads/2014/01/Screen-Shot-2014-01-24-at-14.06.47.png) 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"][](http://theaveragedev.local/wordpress/wp-content/uploads/2014/01/Screen-Shot-2014-01-24-at-14.08.34.png) 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"][](http://theaveragedev.local/wordpress/wp-content/uploads/2014/01/Screen-Shot-2014-01-24-at-14.11.29.png) I hate it.[/caption]