Setting up PHP CodeSniffer for NetBeans to work with MAMP


I ran into an issue using @beberlei's PHP_CodeSniffer plug-in for NetBeans (my current PHP editor, although I do still have a soft spot for ZendStudio, my editor for two years previously).


  • OSX 10.6
  • NetBeans 6.9.1 (reproduced on 6.9 and 6.8 as well)
  • MAMP version 1.9.2
  • PHP_CodeSniffer, installed into /Applications/MAMP/bin/php5.3/lib/php

After installing the plug-in, (with no errors) I went to the plug-in's preferences pane and saw that there was no list coding standards available in the Coding Standards dropdown, and the location of the phpcs binary (part of PHP_CodeSniffer, used by the plug-in) was blank as well. I was able to input its location, but attempting to save/apply the preferences resulted in a NPE.

I was able to resolve this by creating a symlink to the phpcs binary to /usr/bin (a location on my PATH environment variable). As soon as I did that, NB picked up the phpcs location automatically and populated the coding standards dropdown.

cd /usr/bin
sudo ln -s /Applications/MAMP/bin/php5.3/bin/phpcs

Your paths may vary from the above; replace the path in the 2nd line with the location of phpcs on your system.


Tags: netbeans, php