Priti's Technical Corner

October 21, 2016

phpmd for code review

Hello Friends,

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

Available rulesets: cleancode, codesize, controversial, design, naming, unusedcode.

Optional arguments 

  • minimumpriority: rule priority threshold; rules with lower priority than this will not be used
  • reportfile: send report output to a file; default to STDOUT
  • suffixes: comma-separated string of valid source code filename extensions, e.g. php,phtml
  • exclude: comma-separated string of patterns that are used to ignore directories
  • strict: also report those nodes with a @SuppressWarnings annotation

Rule set for PHPMD

To dump phpmd output in a file

On command prompt

phpmd C:\wamp64\www\myproject\models text –reportfile anyfilename.txt  unusedcode, controversial, codesize, cleancode

The interesting thing is you can define the rules as per your projects. An easy CLI tool to keep code neat and clean.

Happy Coding !

September 15, 2015

Symfony installation error – symfony is not recognized as an internal or external command

Referring site – to install symfony on my window 7 machine. While creating a symfony new project I faced an error message while running following command

c:\wamp\www>> php symfony new my_project

“symfony is not recognized as an internal or external command operable program or batch file”

Got puzzled as I just used symfony installer and there are no other steps I missed !.  As per my thoughts if you are on Linux machine and working as Admin then you might not face this error. But, in Window it will if you are not running the command line interface as Administrator.

Steps to solve

Exit the current command line session
Start new command line interface by choosing from properties – “Run as Administrator” .
Hit the command again

c:\wamp\www>> php symfony new my_project

On Success
Preparing project…

OK Symfony 2.7.4 was successfully installed. Now you can:

Hope it help you further in exploring Symfony 🙂

Older Posts »

Create a free website or blog at

%d bloggers like this: