Skip to content

Instantly share code, notes, and snippets.

@davidyell
Last active February 25, 2016 10:04
Show Gist options
  • Save davidyell/4538113 to your computer and use it in GitHub Desktop.
Save davidyell/4538113 to your computer and use it in GitHub Desktop.
Hooking up Netbeans to CodeSniffer

#How to implement CodeSniffer into Netbeans

##Things you will need Netbeans plugin
Download the plugin from here, http://plugins.netbeans.org/plugin/40282/phpmd-php-codesniffer-plugin

PEAR installed
You can test this by typing into a terminal which pear and it should return a path. If you do not have PEAR installed, you can find out how to install it from the site, http://pear.php.net/

PEAR packages
Note
If you get errors whilst installing PEAR packages, try using sudo

pear install PHP_CodeSniffer
http://pear.php.net/package/PHP_CodeSniffer

pear channel-discover pear.phpmd.org
pear channel-discover pear.pdepend.org
pear install --alldeps phpmd/PHP_PMD
http://phpmd.org/

##Install the plugin In Netbeans click Tools > Plugins and click the Downloaded tab. Click on Add Plugins… and browse to where your .nbm file is located. Install this file and restart Netbeans.

##Configuring the plugin Now you need to configure the plugin so it can find your PEAR packages.
You will need to configure this in Preferences.

Click on the PHP tab, and browse to the phpMD tab. Click change and in here specify the path to your phpmd. For me this is /usr/local/Cellar/php53/5.3.17/bin/phpcs but you can test this in a terminal with which phpmd to ge the path.

Now click on phpCodeSniffer tab and do the same as above to enter the path to your phpcs executable.

###Other settings In here I tend to specify that the tabsize is 4 to conform with PSR-2.

##How do I 'run' it? Window > Action items

or CMD + 6

Then you can use the filters on the left to adjust which things it scans. I tend to use the 'paper sheet' icon at the top which is 'current file'. You can then use the funnel icon to specify which things you want displayed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment