PHPackages                             lakshmaji/phpmd - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. lakshmaji/phpmd

ActiveProject[Testing &amp; Quality](/categories/testing)

lakshmaji/phpmd
===============

PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.

2.6.5(8y ago)030BSD-3-ClausePHPPHP &gt;=5.4.0

Since Sep 7Pushed 8y ago1 watchersCompare

[ Source](https://github.com/lakshmaji/phpmd)[ Packagist](https://packagist.org/packages/lakshmaji/phpmd)[ Docs](https://github.com/lakshmaji)[ RSS](/packages/lakshmaji-phpmd/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (4)Versions (34)Used By (0)

PHPMD
=====

[](#phpmd)

PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD. PHPMD can be seen as an user friendly frontend application for the raw metrics stream measured by PHP Depend.

[![Latest Stable Version](https://camo.githubusercontent.com/70fc0da94c1e4f8bf9de6000228a12ea06ce486509fa010b86d92c0eba75f207/68747470733a2f2f706f7365722e707567782e6f72672f7068706d642f7068706d642f762f737461626c652e737667)](https://packagist.org/packages/phpmd/phpmd)[![License](https://camo.githubusercontent.com/6fab692797cff71b66494c4daf050442186b16fb4c06b0bef8028759f63340da/68747470733a2f2f706f7365722e707567782e6f72672f7068706d642f7068706d642f6c6963656e73652e737667)](https://packagist.org/packages/phpmd/phpmd)[![Travis Build Status](https://camo.githubusercontent.com/d841d923ea4622d76b2ecdc36760817d291bed02666b78b6dbab6e2996e07563/68747470733a2f2f7472617669732d63692e6f72672f7068706d642f7068706d642e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/phpmd/phpmd)[![AppVeyor Build Status](https://camo.githubusercontent.com/ebfca02d6bcd8a4350dd87abd20a5a74390f591ce026dda33aa02f7f559f7024/68747470733a2f2f63692e6170707665796f722e636f6d2f6170692f70726f6a656374732f7374617475732f706330386f7762756e327930306b776b3f7376673d74727565)](https://ci.appveyor.com/project/phpmd/phpmd)[![Scrutinizer Build Status](https://camo.githubusercontent.com/22e55c3e66316f76d1e025fe453cc1878649b33838c9cb7dd4989054d86bd559/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068706d642f7068706d642f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpmd/phpmd/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8b7c02e0fd3e868f08472acd3aae2bbcfe386c3a808c9ed5cbb3ed6044e99b7b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7068706d642f7068706d642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/phpmd/phpmd/?branch=master)Installation
------------

[](#installation)

See

Command line usage
------------------

[](#command-line-usage)

Type `phpmd [filename|directory] [report format] [ruleset file]`, i.e:

```
mapi@arwen ~ $ phpmd PHP/Depend/DbusUI/ xml rulesets/codesize.xml
```

While the `rulesets/codesize.xml` ruleset file could look like this:

```

      This class has too many methods, consider refactoring it.

```

You can pass a file name or a directory name containing PHP source code to PHPMD.

The [PHPMD Phar distribution](https://phpmd.org/download/index.html) includes the rule set files inside its archive, even if the "rulesets/codesize.xml" parameter above looks like a filesystem reference.

Command line options
--------------------

[](#command-line-options)

- Notice that the default output is in XML, so you can redirect it to a file and XSLT it or whatever
- You can also use shortened names to refer to the built-in rule sets, like this:

    ```
    phpmd PHP/Depend/DbusUI/ xml codesize
    ```
- The command line interface also accepts the following optional arguments:

    - `--minimumpriority` - The rule priority threshold; rules with lower priority than they will not be used.
    - `--reportfile` - Sends the report output to the specified file, instead of the default output target `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.
    - `--ignore-violations-on-exit` - will exit with a zero code, even if any violations are found.

    An example command line:

    ```
    phpmd PHP/Depend/DbusUI xml codesize --reportfile phpmd.xml --suffixes php,phtml
    ```

### Using multiple rule sets

[](#using-multiple-rule-sets)

PHPMD uses so called rule sets that configure/define a set of rules which will be applied against the source under test. The default distribution of PHPMD is already shipped with a few default sets, that can be used out-of-box. You can call PHPMD's cli tool with a set's name to apply this configuration:

```
~ $ phpmd /path/to/source text codesize
```

But what if you would like to apply more than one rule set against your source? You can also pass a list of rule set names, separated by comma to PHPMD's cli tool:

```
~ $ phpmd /path/to/source text codesize,unusedcode,naming
```

You can also mix custom [rule set files](https://phpmd.org/documentation/creating-a-ruleset.html) with build-in rule sets:

```
~ $ phpmd /path/to/source text codesize,/my/rules.xml
```

That's it. With this behavior you can specify you own combination of rule sets that will check the source code.

### Using multiple source files and folders

[](#using-multiple-source-files-and-folders)

PHPMD also allowes you to specify multiple source directories in case you want to create one output for certain parts of your code

```
~ $ phpmd /path/to/code,index.php,/another/place/with/code text codesize
```

Exit codes
----------

[](#exit-codes)

PHPMD's command line tool currently defines three different exit codes.

- 0, This exit code indicates that everything worked as expected. This means there was no error/exception and PHPMD hasn't detected any rule violation in the code under test.
- *1*, This exit code indicates that an error/exception occured which has interrupted PHPMD during execution.
- *2*, This exit code means that PHPMD has processed the code under test without the occurence of an error/exception, but it has detected rule violations in the analyzed source code. You can also prevent this behaviour with the `--ignore-violations-on-exit` flag, which will result to a 0even if any violations are found.

Renderers
---------

[](#renderers)

At the moment PHPMD comes with the following three renderers:

- *xml*, which formats the report as XML.
- *text*, simple textual format.
- *html*, single HTML file with possible problems.

API docs
--------

[](#api-docs)

You find the up to date class API docs at [codedoc.pub](https://codedoc.pub/phpmd/phpmd/master/index.html).

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 71.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~59 days

Recently: every ~1 days

Total

34

Last Release

3050d ago

Major Versions

1.5.0 → 2.0.0-beta.12014-03-13

1.5.x-dev → 2.1.22014-09-25

PHP version history (3 changes)1.4.0PHP &gt;=5.3.0

2.4.4PHP &gt;=5.3.9

2.6.1PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/14037682?v=4)[Lakshmaji](/maintainers/lakshmaji)[@lakshmaji](https://github.com/lakshmaji)

---

Top Contributors

[![manuelpichler](https://avatars.githubusercontent.com/u/58714?v=4)](https://github.com/manuelpichler "manuelpichler (865 commits)")[![ravage84](https://avatars.githubusercontent.com/u/625761?v=4)](https://github.com/ravage84 "ravage84 (209 commits)")[![eeree](https://avatars.githubusercontent.com/u/1375008?v=4)](https://github.com/eeree "eeree (32 commits)")[![beberlei](https://avatars.githubusercontent.com/u/26936?v=4)](https://github.com/beberlei "beberlei (14 commits)")[![JeroenDeDauw](https://avatars.githubusercontent.com/u/146040?v=4)](https://github.com/JeroenDeDauw "JeroenDeDauw (11 commits)")[![zerkalica](https://avatars.githubusercontent.com/u/274786?v=4)](https://github.com/zerkalica "zerkalica (6 commits)")[![jaymoulin](https://avatars.githubusercontent.com/u/14236493?v=4)](https://github.com/jaymoulin "jaymoulin (6 commits)")[![sebbrandt87](https://avatars.githubusercontent.com/u/793580?v=4)](https://github.com/sebbrandt87 "sebbrandt87 (5 commits)")[![dudemelo](https://avatars.githubusercontent.com/u/1172271?v=4)](https://github.com/dudemelo "dudemelo (4 commits)")[![addiks](https://avatars.githubusercontent.com/u/3450330?v=4)](https://github.com/addiks "addiks (4 commits)")[![rafalwrzeszcz](https://avatars.githubusercontent.com/u/633614?v=4)](https://github.com/rafalwrzeszcz "rafalwrzeszcz (4 commits)")[![sebastianbergmann](https://avatars.githubusercontent.com/u/25218?v=4)](https://github.com/sebastianbergmann "sebastianbergmann (4 commits)")[![timmartin](https://avatars.githubusercontent.com/u/56920?v=4)](https://github.com/timmartin "timmartin (4 commits)")[![gooh](https://avatars.githubusercontent.com/u/370948?v=4)](https://github.com/gooh "gooh (3 commits)")[![naderman](https://avatars.githubusercontent.com/u/154844?v=4)](https://github.com/naderman "naderman (3 commits)")[![ptlis](https://avatars.githubusercontent.com/u/508422?v=4)](https://github.com/ptlis "ptlis (3 commits)")[![francisbesset](https://avatars.githubusercontent.com/u/471525?v=4)](https://github.com/francisbesset "francisbesset (3 commits)")[![gennadiylitvinyuk](https://avatars.githubusercontent.com/u/674894?v=4)](https://github.com/gennadiylitvinyuk "gennadiylitvinyuk (3 commits)")[![Gisleburt](https://avatars.githubusercontent.com/u/2369524?v=4)](https://github.com/Gisleburt "Gisleburt (3 commits)")[![svscorp](https://avatars.githubusercontent.com/u/475464?v=4)](https://github.com/svscorp "svscorp (2 commits)")

---

Tags

pdependphpmdpmdmess detectionmess detector

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/lakshmaji-phpmd/health.svg)

```
[![Health](https://phpackages.com/badges/lakshmaji-phpmd/health.svg)](https://phpackages.com/packages/lakshmaji-phpmd)
```

###  Alternatives

[phpmd/phpmd

PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.

2.4k108.5M4.8k](/packages/phpmd-phpmd)[pdepend/pdepend

Official version of pdepend to be handled with Composer

954110.9M815](/packages/pdepend-pdepend)[jbzoo/ci-report-converter

The tool converts different error reporting standards for deep integration with popular CI systems (TeamCity, IntelliJ IDEA, GitHub Actions, etc)

30784.4k2](/packages/jbzoo-ci-report-converter)[mi-schi/phpmd-extension

Contains extra phpmd rules from clean code book and the best practices of my experiences.

40882.0k5](/packages/mi-schi-phpmd-extension)[sci3ma/symfony-grumphp

Configured GrumPHP with bunch of tools for static code analysis Symfony Framework

196.7k](/packages/sci3ma-symfony-grumphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
