开发者

How to configure phpMD plugin in NetBeans 6.9 (Ubuntu)

开发者 https://www.devze.com 2023-02-27 12:24 出处:网络
I\'ve written a custom XML ruleset, so I run phpmd with the following command: phpmd /path/to/my/file.modul开发者_StackOverflow社区e xml ruleset.xml

I've written a custom XML ruleset, so I run phpmd with the following command:

phpmd /path/to/my/file.modul开发者_StackOverflow社区e xml ruleset.xml

Now I've downloaded and installed the phpmd/CodeSniffer plugin for netbeans (http://sourceforge.net/projects/phpmdnb/files/), but I can't find the way to configure it properly.

Going to Tools -> Options -> PHP, I find the phpMD tab, in which I can change settings.

No idea what to put in each field.

If I put the binary in the field "phpMD batch file:", netbeans throws the error "The file /usr/bin/phpmd isn't the right phpMD batch".

Has anyone successfully installed this interesting plugin?


you must place your ruleset file into the default phpmd folder "rulesets" which is normaly located at $PEAR/data/PHP_PMD/rulesets/.
Now you can simply set the ruleset name in NetBeans PHP-MD Plugin configuration.
As batch file you must choose phpmd from your php binary folder.

If you still get any errors, please submit a bug report on the plugin page http://sourceforge.net/projects/phpmdnb/

Hope this would help.


Carles,

I haven't played with this particular plugin. However, approach I've used for workarounding other plugins' issues could help here as well.

So the approach is to create a wrapper script. That could be bash, for example, on Linix/Mac or bar on Windows. Use this wrapper in plugin settings as main executable. With this approach you can gain full flexibility - you can pass whatever parameters you want and so on. NetBeans may (and most likely will) pass some parameters to that script (depending on plugin). That is quite easy to debug. Here is an example of such wrapper in bash, written for PHPUnit:

#!/bin/bash
#

localInputFile=${7:4}
localJUnitLog=$2
localCoverageLog=$4
remoteInputFile=`echo $localInputFile | sed "s|$localPath|$remotePath|g"`

remoteJUnitLog=${remotePath}nb-phpunit-log.xml
remoteJUnitLoginLocalFilePath=${localPath}nb-phpunit-log.xml
remoteCoverageLog=${remotePath}nb-phpunit-coverageClover.xml
remoteCoverageLoginLocalFilePath=${localPath}nb-phpunit-coverageClover.xml
remoteCoverageLoginLocalFilePathNew=${remoteCoverageLoginLocalFilePath}new

ssh root@<remote-server> "phpunit --colors --log-junit $remoteJUnitLog --coverage-clover $remoteCoverageLog $remoteInputFile"
cp $remoteJUnitLoginLocalFilePath $localJUnitLog
sed "s|$remotePath|$localPath|g" $remoteCoverageLoginLocalFilePath > $remoteCoverageLoginLocalFilePathNew
cp $remoteCoverageLoginLocalFilePathNew $localCoverageLog

This one I've used to force PHPUnit NetBeans plugin to use phpunit not at localhost, but at the remote server. But what you need here is the way parameters are caught. You could debug that doing just

echo $0 $1 $2

and opening output window in Netbeans to see the result.

Hope this would help.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号