Installing the CodeIgniter plugin for PHP_CodeSniffer

Since reading Phil Sturgeon’s post on PHP Static Analysis in the Sublime text editor, I have been experimenting with using phpcs and Sublime in general. Since I am currently used to the CodeIgniter coding standard, the time finally came today to try and configure my setup for that standard instead of PSR-2.

(A downgrade? Perhaps, but it’s what we use at work and it fits better into my workflow at the moment. Besides, the PSR-2 bracket rules annoy me to no end.)

After installing phpcs on top of my homebrewed php54 installation, adding the CodeIgniter standard to PHP_CodeSniffer was a little more tricky than expected. The catch is to specify the correct path to the PEAR module in the ant build script, which is NOT the same thing as the path to the phpcs command:

sudo ant -Dphpcs.dir=/usr/local/Cellar/php54/5.4.19/lib/php/PHP/CodeSniffer/

After that, we’re off to the races. Verifying that the install works:

$ /usr/local/Cellar/php54/5.4.19/bin/phpcs -iThe installed coding standards are CodeIgniter, MySource, PEAR, PHPCS, PSR1, PSR2, Squiz and Zend

Great! Now just change the phpcs settings in the Sublime PHP Code Sniffer config file to CodeIgniter, and we’re done.

"phpcs_additional_args": {
 "--standard": "CodeIgniter",
 "-n": ""

One thought on “Installing the CodeIgniter plugin for PHP_CodeSniffer”

  1. This is great! One of the only posts I’ve seen that tells how to do this. Only thing is when I run the sudo ant ... command, it responds:

    build.xml does not exist!
    Build failed

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>