Skip to main content


Supported VersionLanguageWebsite

PHPMD is a static analysis tool focused on detecting code smells and possible errors in your PHP code.

Getting Started#

To start using PHPMD, enable it in your repository settings.

Default Configuration for PHPMD#

Sider provides our recommended ruleset for PHPMD. This configuration is used when the rule option is not specified in sider.yml in your repository. For more details, please visit Recommended Ruleset.

Performance Issues#

PHPMD sometimes raises analysis timeout with a larger codebase.

To mitigate this, Sider deletes files that are not changed in the pull request. This behavior is automatically done and cannot be disabled.

If PHPMD still raises timeout, you can reduce target files of PHPMD analysis by using the target option:

linter:  phpmd:    target:      - index.php      - wp-content/


Here is an example configuration via sider.yml:

linter:  phpmd:    target:      - index.php      - wp-content/    rule:      - codesize      - unusedcode      - my_custom_ruleset.xml    minimumpriority: 3    suffixes: [php, phtml]    exclude:      - app/vendor/      - "test/*.php"    strict: true    custom_rule_path:      - Custom_PHPMD_Rule.php      - "custom/phpmd/rules/**/*.php"

You can use several options to fine-tune PHPMD to your project:

targetstring, string[].
rulestring, string[](see below)
suffixesstring, string[]php
excludestring, string[]-

See also the PHPMD document for details.


This option allows you to specify files or directories to analyze.


This option allows you to specify the predefined ruleset names or your custom ruleset file paths. The value can be a comma-separated list.

Here are the available rulesets:

  • cleancode
  • codesize
  • controversial
  • design
  • naming
  • unusedcode

If omitted, Sider uses the recommended ruleset.

If you want to learn more, see the PHPMD ruleset document.


This option allows you to specify the rule priority threshold. Rules with lower priority than the specified value will not be reported.


This option allows you to specify file extensions to analyze. Use a comma-separated list for multiple values, e.g. php,phtml.


This option allows you to specify directories to exclude from analysis objects. You can use asterisk patterns and use a comma-separated list for multiple values, e.g. src/foo/*.php,*src/foo/*.


This option allows you to specify whether reports nodes that have the @SuppressWarnings annotation or not.


This option allows you to specify your own custom rule PHP file paths. Glob pattern is also available. You need to use it along with the rule option. For example:

# sider.ymllinter:  phpmd:    rule: custom_ruleset.xml    custom_rule_path:      - Custom_PHPMD_Rule.php      - "custom/phpmd/rules/**/*.php"
<!-- custom_ruleset.xml --><?xml version="1.0" encoding="utf-8"?><ruleset name="Your Custom Ruleset">  <rule name="SomeYourCustomRule"        message="Please do not this."        class="Custom_PHPMD_Rule"        externalInfoUrl="">    <priority>1</priority>  </rule></ruleset>