PHP CodeSniffer Support for Netbeans

I dived into the code of my new favorite IDE Netbeans these last days and came up with an extension module, which adds PHP CodeSniffer Support on a per file basis to make my life much easier. It shows warnings and errors as annotations to the Editor and marks the affected lines in yellow and red.

My Java skills being very bad, it will only work on Linux currently, since the PHP Code Sniffer "binary" is hardcoded into the Java Source code. You have to create a "/usr/bin/phpcs2" executable, which is a wrapper that looks like:

With Manuals extensions (see the comments) the module now works without the wrapper script. It might even work under Windows now. Yet now the Zend Coding standard is enforced though. I am working on making that one configurable next.

You can install the NBM module install file from the GitHub repository into Netbeans and it "should" work then.

I hope to get more familiar with Netbeans in the future to add some more PHP tools and enhance Code Sniffer support.

Share This Post

  • Share on Twitter
  • Facebook
  • Share on deli.cio.us
  • Share on Digg
  • Share on reddit
  • Share on StumbleUpon

Comments


robo47
Jul, 31. 2009

Really great. Thx for the great work.

Since the .nbm didn't work in 6.7.1 and in the latest 6.8 nightly, I build it myself in 6.7.1 from the git master (50ee09a6caf88e9b1e69a4896122363677e87c68), but in the latest 6.8 nightly netbeans seems to miss org.netbeans.modules.php.project.util.PhpProgram;

Current Problem running it on 6.7.1:

After running it once on a file, then changing something, running it again doesn't change any annotations.

A new "code-check" is only possible after restarting netbeans.

But it's really great to have phpcs IN netbeans :)
after phpunit in netbeans, netbeans is really getting better for php-development from day to day.



manuel pichler
Jul, 31. 2009

I was so free to fork your netbeans plugin to remove the requirement of an external CodeSniffer script. Additionally I have replaced the hard coded binary location with a dynamic lookup based on the environment's $PATH variable. The context menu entry will be disabled when this lookup method does not find a *phpcs* binary.

By the way, really great work...

Greetings
Manuel



zilvinas
Jul, 31. 2009

It would be great to have something like this for eclipse.



johny
Jul, 31. 2009

I even like Netbeans more than Zend-Eclipse at the moment but what you described here is one of the reasons why i changed. Either a plugin works or not i don´t like something wich only works mostly and sometimes with some extra changes wich could be found in some different posts arround the Web.
So i could live without code sniffer before and not gonna install it untill it works fine.



tomas.pet
Aug, 08. 2009

Seems great, but I have litte problem. When I try to install *.nbm file, Neatbeans says: "Some plugins require plugin PHP Project to be installed.
The plugin PHP Project is requested in implementation version 200906241340".

Am I missing something ?

Thanks in advance.



yannux
Aug, 13. 2009

Same as tomas.pet



raphael
Aug, 18. 2009

Same here.



igoru-san
Aug, 20. 2009

I'm getting the same problem.... I'm running Netbeans 6.7 at Windows. Any help?



beberlei
Aug, 20. 2009

hm thats above my skills already, i think its either about netbeans 6.7.1 vs 6.7 maybe?

I am using some PHP API that is not public yet, therefore the version is quite important. I should refactor away from the unstable API for the next version.



viego
Oct, 03. 2009

I tried installing your Plugin, but the only think I get is this errormessage:

Some plugins require plugin PHP Project to be installed.
The plugin PHP Project is requested in implementation version 200906241340. The following plugin is affected:       phpcs2

Perhaps you can fix this problem. It occurs on Netbeans 6.7.1 on MacosX and Debian Linux.



nyc000
Oct, 05. 2009

I installed the NBM from the link above without any issues on the latest build on OSX, but I don't seem to see any new options. What am I missing?



nyc000
Oct, 05. 2009

Forgot to mention I do have phpcs setup, runs fine from Terminal



beberlei
Oct, 05. 2009

See http://www.whitewashing.de/blog/articles/121 for a new version!



jxmynfhmg
Jul, 23. 2010

N0anR0 <a href="http://dolmbysfrenc.com/">dolmbysfrenc</a>, [url=http://zlszyyosauyw.com/]zlszyyosauyw[/url], [link=http://zmnxklglkvsr.com/]zmnxklglkvsr[/link], http://ddpsopwldxml.com/


Write a Comment