PHPMD for VS Code
PHP Mess Detector integration for Visual Studio Code.
Features
- Analyze the current PHP file via command palette or editor context menu
- Analyze multiple files and folders via Explorer context menu
- Inline diagnostics — lint on save highlights violations without leaving the editor
- Output channel with detailed PHPMD output
- Configurable rulesets, minimum priority, and executable path
Requirements
- PHPMD installed globally or in the project:
composer global require phpmd/phpmd
# or
composer require --dev phpmd/phpmd
Configuration
| Setting |
Type |
Default |
Description |
phpmd.enabled |
boolean |
true |
Enable or disable the extension |
phpmd.executablePath |
string |
"phpmd" |
Path to the PHPMD executable. Supports ${workspaceFolder}, ~ |
phpmd.rulesets |
string |
"cleancode,codesize,controversial,design,naming,unusedcode" |
Comma-separated rulesets or path to a custom ruleset XML file |
phpmd.minimumPriority |
number |
5 |
Report violations with priority ≤ this value (1 = highest) |
phpmd.lintOnSave |
boolean |
false |
Run PHPMD on save and show inline diagnostics |
phpmd.timeout |
number |
60000 |
Maximum time (ms) to wait for PHPMD |
Example .vscode/settings.json
{
"phpmd.enabled": true,
"phpmd.executablePath": "${workspaceFolder}/vendor/bin/phpmd",
"phpmd.rulesets": "cleancode,codesize,naming,unusedcode",
"phpmd.minimumPriority": 3,
"phpmd.lintOnSave": true
}
Commands
| Command |
Description |
PHPMD: Analyze Current File |
Run PHPMD on the active PHP file |
PHPMD: Analyze Selected Files/Folders |
Run PHPMD on items selected in the Explorer |
PHPMD: Show Output |
Open the PHPMD output channel |
License
MIT
| |