Skip to content

Configuration

mir can be configured through CLI flags and an optional XML config file (mir.xml). There is no required config file — mir works out of the box with sensible defaults.

When run, mir searches upward from the current directory for mir.xml. If no mir.xml is found, it falls back to psalm.xml (Psalm compatibility). You can also point to a config file explicitly with -c.

<?xml version="1.0"?>
<mir xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" errorLevel="3">
<projectFiles>
<directory name="src" />
<directory name="lib" />
</projectFiles>
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
<issueHandlers>
<UndefinedVariable errorLevel="suppress" />
<PossiblyNullReference errorLevel="warning" />
</issueHandlers>
<phpVersion>8.2</phpVersion>
<findUnusedCode>true</findUnusedCode>
<findUnusedVariables>true</findUnusedVariables>
</mir>
FieldDescription
errorLevel attributeGlobal strictness: 1 (errors only) to 8 (lenient). Default: 2.
<projectFiles>Source directories to analyze.
<ignoreFiles>Directories or files to exclude (e.g. vendor/).
<issueHandlers>Per-issue-kind severity overrides (see below).
<phpVersion>Target PHP version string, e.g. 8.2.
<findUnusedCode>Enable dead-code detection (true/false). Default: false.
<findUnusedVariables>Enable unused-variable checking (true/false). Default: false.

Each child element of <issueHandlers> is an issue kind name with an errorLevel attribute:

LevelEffect
errorTreat as error (exit code 1)
warningTreat as warning
infoTreat as info (only shown with --show-info or errorLevel >= 7)
suppressSilence the issue entirely
<issueHandlers>
<UndefinedMethod errorLevel="suppress" />
<InvalidArgument errorLevel="warning" />
</issueHandlers>

CLI flags always override values from the config file.

FlagDefaultDescription
-c, --config <FILE>autoConfig file path. Auto-discovers mir.xml / psalm.xml if omitted.
--baseline <FILE>autoSuppress known issues from a baseline XML. Auto-discovers psalm-baseline.xml.
--set-baseline [FILE]psalm-baseline.xmlWrite all current issues to a baseline file and exit.
--update-baselineoffRemove resolved issues from the baseline.
--ignore-baselineoffReport all issues, ignoring the baseline.
--error-level <1-8>from configOverride global error level.
--php-version <X.Y>from configTarget PHP version (e.g. 8.2).
--format <FORMAT>textOutput format: text, json, github, junit, sarif.
--show-infooffInclude info-level issues (redundancies, style).
-j, --threads <N>CPU countParallelism.
--cache-dir <DIR>offEnable incremental cache in DIR.
--statsoffPrint file count, error/warning totals, elapsed time.
-v, --verboseoffPrint per-file issue counts.
-q, --quietoffSuppress all output; use exit code only.
--no-progressoffDisable the progress bar.

A baseline file records known issues so that they are suppressed on future runs. This lets you adopt mir incrementally — silence pre-existing issues and focus on new ones as they are introduced.

Baseline files use Psalm’s XML format, so an existing psalm-baseline.xml works directly.

Terminal window
# 1. Generate a baseline from the current issues (first adoption)
mir --set-baseline psalm-baseline.xml src/
# 2. Subsequent runs suppress baselined issues automatically
# (psalm-baseline.xml in the cwd is picked up automatically)
mir src/
# 3. Explicitly point to a baseline in a non-standard location
mir --baseline path/to/my-baseline.xml src/
# 4. After fixing issues, shrink the baseline (removes resolved entries)
mir --update-baseline src/
# 5. Temporarily ignore the baseline to see all issues
mir --ignore-baseline src/
<?xml version="1.0"?>
<mir errorLevel="3">
<projectFiles>
<directory name="src" />
</projectFiles>
<ignoreFiles>
<directory name="vendor" />
</ignoreFiles>
</mir>
Terminal window
# In .github/workflows/mir.yml:
mir --format github --no-progress --baseline psalm-baseline.xml src/

Strict analysis (errors only, no warnings)

Section titled “Strict analysis (errors only, no warnings)”
Terminal window
mir --error-level 1 src/
Terminal window
mir --php-version 8.1 src/
<issueHandlers>
<UndefinedMethod errorLevel="suppress" />
</issueHandlers>
Terminal window
mir --cache-dir .mir-cache src/