Skip to content


You can use JSON, YAML or INI files to configure PhpMetrics, with the `--config= option.

Full example a configuration file:

composer: false  # Analyse the composer.* files
includes:  #  directory and files to analyze, relative to config file directory
    - "src"
excludes: # regex of files (or directory) to exclude from analyze
    - tests
extensions: # default: ["php", "inc"]
    - php
    - php8
report: # list of reports to generate
    html: "/tmp/report/"
    csv: "/tmp/report.csv"
    json: "/tmp/report.json"
    violations: "/tmp/violations.xml"

# "layers" of code. You can group your classes and packages by regex,
# to visualise specific HTML report for each of them
    - name: Component   
      match: "!component!i" # regex to match the group
    - name: Hexagon
      match: "!hexagon!i"
        binary: git # if defined, runs git analyze
        file: "/tmp/junit.xml" # if defined, analyze junit report

# You can define patterns of code to search
# That's useful for Continuous Integration
    Repository which uses Service: # You can name your search as you want
        type: class
            - App\MyRepository
        nameMatches: ".*Repository.*"
            - ".*Service"
        failIfFound: true # stop execution if pattern of code is found
    Class with too complex code:
        type: class
        ccn: ">=10"
        failIfFound: true
    Class with too many responsabilitites:
        type: class
        lcom: ">=3"
        failIfFound: true
    Controller which use doctrine:
        type: class
        nameMatches: ".*Controller.*"
            - ".*Connection.*"
        failIfFound: true
Back to top