Warnings on running phpcs -i for SublimeLinter

Warning: include_once(PHP/CodeSniffer/CLI.php): failed to open stream: No such file or directory in /usr/bin/phpcs on line 31

Warning: include_once(): Failed opening ‘PHP/CodeSniffer/CLI.php’ for inclusion (include_path=’.:’) in /usr/bin/phpcs on line 31

Fatal error: Class ‘PHP_CodeSniffer_CLI’ not found in /usr/bin/phpcs on line 34
If you are seeing the above errors when running phpcs (PHPCodeSniffer) first thing you have to do is to make sure you have PHPCodeSniffer installed. To check this just open a Terminal and run:

find / -type f -name 'CLI.php'

If you see in the results something like this …..lib/php/PHP/CodeSniffer/CLI.php then you have code sniffer installed. In case you haven’t then run sudo pear install PHP_CodeSniffer to install it.

Then all you have to do is to include the folder in your path. Just copy in your clipboard everyhing behind /PHP/CodeSniffer/CLI.php. In my case it was “/Applications/MAMP/bin/php/php5.4.26/lib/php” and paste it in your bash profile file which usually is ~/.bash_profile

So just type nano ~/.bash_profile and paste in there something like this:

export PATH=/Applications/MAMP/bin/php/php5.4.26/lib/php:$PATH