October 21, 2016

I use phpmd for code reviews. It is quick and easy to setup. Provides me first hand information about sub optimal code, over complicated experssion,Unused parameters, methods, properties and suggestions for refactoring class and functions.

Install phpmd

Add in your composer.json of your project

“require-dev”: {

“phpmd/phpmd” : “@stable”

}

Command prompt >phpmd /path/to/directory/for/php/class text

You may get following error sometimes

‘phpmd’ is not recognized as internal or external command

on command prompt run

> composer global require phpmd/phpmd

Mandatory arguments:

1) A php source code filename or directory. Can be a comma-separated string

2) A report format (It can be Text, Html, XML)

3) A ruleset filename or a comma-separated string of ruleset filenames