How to install PHP Code Sniffer + PHPStorm

This post will help us to keep our code clean under the coding standard PSR2, highlighting on our IDE in this case PHPStorm all the mistakes that we got in our code and how to fix them, pretty useful.


I'm assuming here that we are all Mac users and we got hombrew installed and running, if that is not the case you should install it first, you can follow my old and probably deprecated post PHP on Mavericks with Hombrew or just Google it is not that complicated

Install PHP Code Sniffer

As simple as run the following command:

brew install php-code-sniffer  

Configure PHPStorm

Open PHPStorm settings Shift+CMD+, search for Code Sniffer and add to the path the exectutable.


Then if you search again for Code Sniffer as we did before you will find the Inspectors options, just need to tick PHP Code Sniffer and pick up the Coding Standard we wantted to use, as simple as that.