Generated by GPT-5-mini| PHPMD | |
|---|---|
| Name | PHPMD |
| Title | PHPMD |
| Latest release version | 2.10.0 |
| Programming language | PHP |
| Operating system | Cross-platform |
| License | BSD-3-Clause |
PHPMD is a static analysis tool for PHP designed to detect potential bugs, dead code, suboptimal code, and maintainability issues. It inspects PHP source files and reports violations against a configurable set of rules, helping developers, teams, and organizations improve code quality. PHPMD is commonly used in continuous integration pipelines and local development alongside linters, formatters, and testing frameworks to maintain software reliability.
PHPMD analyzes PHP code to produce machine-readable and human-readable reports that highlight complexity, duplication, and unused elements. It complements tools such as PHPUnit, PHPCS, Composer (software), Docker, Travis CI, Jenkins, and GitLab CI/CD by focusing on design and maintainability rather than unit test assertions. The tool reads abstract syntax trees and metric calculations to identify code smells and anti-patterns that can arise in projects ranging from small libraries to large applications like those maintained by organizations such as Symfony (software) foundations or companies using Laravel (web framework) stacks. PHPMD is often paired with static analyzers like Psalm (software) and PHPStan and with code review platforms such as Gerrit and GitHub.
PHPMD ships with a collection of built-in rules grouped into rulesets tailored for common quality concerns. Default rulesets include detectors for unused code elements, overly complex methods, excessive coupling, and naming conventions. The rulesets are configurable and can be extended: users can enable or disable specific rules, write custom detectors, or import rules from other projects. Typical analyses report on cyclomatic complexity, excessive parameters, long methods, and dead private code, which relate to metrics used in projects like Eclipse Foundation tooling or corporate quality gates enforced by firms such as Atlassian and Red Hat. Output formats supported by PHPMD include text, XML, JSON, and lightweight markup, facilitating integration with products like SonarQube, Sentry (company), New Relic, and JIRA for issue tracking.
PHPMD is distributed via Composer (software) and can be installed globally or per-project. Common installation commands interact with repositories managed by Packagist and often run in containerized environments provisioned by Kubernetes or orchestrated with Docker Compose. Basic usage invokes the PHPMD binary with arguments specifying target directories, a chosen ruleset, and an output format; typical CI jobs execute PHPMD in the same stage as linters and unit tests alongside runners such as CircleCI, Azure DevOps, and Bitbucket Pipelines. Logs and artifacts produced by PHPMD are consumed by downstream tools including Elastic Stack, Splunk, and Datadog for centralized monitoring and historical trend analysis. Developers integrate PHPMD into editor workflows using plugins for editors like Visual Studio Code, PhpStorm, Sublime Text, and Vim.
PHPMD integrates with a broad ecosystem of development and quality-assurance tooling. It is invoked from build systems such as Make (software), Phing, and continuous integration servers such as TeamCity and Bamboo (software). Teams incorporate PHPMD findings into code review processes using platforms like GitHub, GitLab, Phabricator, and Bitbucket Cloud. For enterprise environments, PHPMD reports are piped into quality dashboards provided by SonarQube or proprietary systems built on Grafana and Prometheus. Integration plugins and community-driven adapters exist for IDEs and editors produced by companies like JetBrains and Microsoft to surface warnings inline while coding.
PHPMD rulesets are XML-based and allow fine-grained control: rules can be parameterized, disabled, or combined into custom suites. Projects commonly maintain a ruleset committed to the repository to ensure consistent enforcement across developer machines and CI agents managed by organizations such as Google or Amazon Web Services. Custom rule development requires familiarity with the PHP Parser library and may involve extending visitor patterns used in other tools developed by the PHP-FIG community or contributors from institutions similar to Linux Foundation projects. Teams often map PHPMD rule severities to organizational policies and ticketing workflows in systems like JIRA, ServiceNow, or Azure Boards.
PHPMD originated as a successor to tools that targeted code smells and maintainability in PHP, evolving through community contributions and forks maintained in public repositories on platforms such as GitHub. Its maintenance model has involved volunteer maintainers, corporate contributors, and community reviewers, similar to other open-source projects overseen by organizations like The Apache Software Foundation or The Eclipse Foundation. Release cadence has followed semantic versioning practices with changelogs documenting rule additions, bug fixes, and compatibility updates for PHP language versions released by the PHP Group. Ongoing maintenance often intersects with PHP ecosystem shifts embodied by frameworks like Zend Framework and runtime changes introduced by HHVM efforts, requiring continuous updates to parsing logic and test suites maintained by contributors affiliated with universities, companies, and user groups across regions including Europe, North America, and Asia.
Category:Static analysis tools