---
title: pun.toml
description: Paths, exclusions, presets, rule levels, and options.
---

[`pun init`](/docs/commands/init) creates `pun.toml`, and [`pun migrate`](/docs/commands/migrate) converts existing configs. Every section is optional. Dependencies stay in [`composer.json`](#dependencies).

```toml pun.toml
[php]
version = "8.4"

[files]
paths = ["app", "tests"]
exclude = ["build", "storage"]

[extensions]
laravel = "on"
pest = "on"

[format]
preset = "laravel"
exclude = ["app/Generated"]
not-name = ["*.blade.php"]
not-path = ["app/Legacy.php"]

[format.rules]
"imports/ordered" = { sort = "length", case-sensitive = true }
"operators/concat-spacing" = "one"
"arrays/syntax" = false

[lint]
sets = ["dead-code", "modernize"]

[lint.groups]
style = "warn"

[lint.rules]
"style/require-final-class" = "error"
"style/require-ordered-traits" = { level = "warn", fix = "off" }
"types/no-loose-comparison" = "off"

[[lint.overrides]]
files = ["tests/**"]
rules = { "style/require-final-class" = "off" }

[analyse]
preset = "recommended"
exclude = ["tests/**"]

[analyse.rules]
"types/missing-return-type" = "off"
```

## [php] and [files]

| Key | Meaning |
| --- | --- |
| `[php] version` | Target PHP version as `major.minor`. Default: the lowest version `require.php` in `composer.json` allows, otherwise 8.4. Without this key, `pun analyse` uses `config.platform.php`, otherwise 8.5 |
| `[files] paths` | Paths to check when the command line gives none. A path outside the project, directly or through a symlink, is a config error |
| `[files] exclude` | Exclusions for every command, added to each command's own `exclude` |

A `require.php` that allows PHP below 8.4 is a config error. Pun never checks `vendor/` or dot folders such as `.git`.

An entry with `*`, `?`, `[`, or `{` is a glob from the project root, and `*` also matches `/`. For example, `storage/**` skips `storage`, not `app/storage`.

A plain entry is a path from the project root, except in format, which matches a folder of that name at any depth, as Pint does. With `exclude = ["tmp"]`, format skips `tmp/` and `app/tmp/`, while lint and analyse skip only `tmp/`. To skip a folder at any depth in every command, write `**/tmp`. [`pun list-files --command <command>`](/docs/commands/list-files) shows the files each command selects.

## [extensions]

Extensions add the rules and analysis for a framework or test tool. Each one is off until `[extensions]` turns it on, so `pun.toml` alone shows what runs. [`pun migrate`](/docs/commands/migrate) and [`pun init`](/docs/commands/init) turn on each extension whose package [`composer.lock`](#dependencies) locks.

| Extension | Package `pun migrate` looks for | What it turns on |
| --- | --- | --- |
| `laravel` | `laravel/framework` | The `laravel` lint rules, the `laravel` analyse rules up to your preset, and Larastan's analysis |
| `pest` | `pestphp/pest` | The `pest` lint rules |
| `phpunit` | `phpunit/phpunit` | The `phpunit` lint rules |

| Value | Effect |
| --- | --- |
| `"on"` | On for every command |
| `"off"`, or left out | Off |

An extension that is on brings its lint rules whatever `[lint] sets` lists. Its opinionated rules and its upgrade groups, such as `laravel-12`, stay opt-in: name them in `[lint.rules]` or `[lint.groups]`. To turn part of an extension off, set its group to `"off"` in `[lint.groups]` or `[analyse.rules]`, or a single rule to `"off"`. A rule you name in `[lint.rules]` runs even when its extension is off.

Format rules don't depend on extensions: Blade formatting is `"laravel/blade" = true` in `[format.rules]`, which `pun migrate` writes only when `pint.json` turns it on. An unknown extension name is a config error. [`pun extension list`](/docs/commands/extension) shows which extensions are on, and why.

## [format]

| Key | Meaning |
| --- | --- |
| `preset` | `laravel` (default), `psr12`, or `empty` |
| `exclude` | Added to `[files] exclude` for format only |
| `not-name`, `not-path` | File names and paths to skip, as in Pint. PHP regular expressions work. An invalid regex is a run error |
| `rules` | `true`, `false`, a table of options, or the value of the rule's only option |

Format always indents with four spaces and writes `\n` line endings. Neither has a setting. Risky and code-deleting fixers are [lint rules](/docs/commands/lint).

## [lint]

| Key | Meaning |
| --- | --- |
| `sets` | [Lint sets](/docs/configuration/presets#lint-sets) to turn on: `dead-code`, `modernize`, `code-quality`, `types`, `early-return`, `privatization`, `naming`, `coding-style` |
| `exclude` | Added to `[files] exclude` for lint only |
| `groups` | `"error"`, `"warn"`, or `"off"` for every rule in a group |
| `rules` | `"error"`, `"warn"`, or `"off"` (not `true` or `false`), or a table with `level`, `fix = "off"`, and the rule's options. `level` defaults to `"error"` |
| `[[lint.overrides]]` | `files` (globs) and `rules`: rule levels for matching files |

Later settings win, in this order:

1. Sets, at `"error"`.
2. Groups.
3. Rules.
4. Matching overrides, in the order they appear.
5. `-A`, `-W`, and `-D` on the command line, in argument order.

Warnings don't fail the run unless you set a warning limit. `--fix` skips rules with `fix = "off"`.

Laravel, Pest, and PHPUnit rules come from [`[extensions]`](#extensions), not from sets. PHP upgrade rules depend on `[php] version`. Groups such as `laravel-12` turn on only when you name them.

## [analyse]

| Key | Meaning |
| --- | --- |
| `preset` | `basic`, `essential`, `recommended` (default), `strict`, or `max`. Each includes the ones before it |
| `paths` | Paths to analyse, instead of `[files] paths` |
| `exclude` | Added to `[files] exclude` for analyse only |
| `baseline` | The baseline file. A path outside the project is a config error |
| `stubs` | Stub files whose PHPDoc refines vendor symbols, as PHPStan's `stubFiles` |
| `bleeding-edge` | `true` infers types as PHPStan's `bleedingEdge.neon` does, except sealed and unsealed array shapes. Default `false` |
| `rules` | `"on"`, `"off"`, or a table of options per rule. `"on"` or `"off"` per group |
| `[[analyse.ignore]]` | Errors to ignore, as PHPStan's `ignoreErrors` |

Every analyse finding is an error.

Each `[[analyse.ignore]]` entry takes these keys. An error is ignored when it matches every key given.

| Key | Matches |
| --- | --- |
| `rule` | A Pun rule ID |
| `identifier` | An error identifier |
| `message` | A PCRE pattern |
| `raw-message` | The exact message |
| `paths` | Paths or fnmatch patterns from the project root |
| `count` | The number of matches, with one path |
| `report-unmatched` | `false` doesn't report the entry when it matches nothing, as PHPStan's `reportUnmatched`. Default `true` |

An entry that matches nothing, or a `count` that is wrong, is reported as an error. With `report-unmatched = false`, only a `count` that is exceeded is.

```toml pun.toml
[[analyse.ignore]]
rule = "undefined/method"
message = "#^Call to an undefined method App\\\\Models\\\\User::#"
paths = ["app/Http/*"]
```

## [workspace]

`members` lists the package directories of a workspace, or globs that match them. Each member has its own `composer.json`. See [workspaces](/docs/guides/workspaces).

```toml pun.toml
[workspace]
members = ["packages/*"]
```

## Dependencies

Dependencies live in `composer.json` and `composer.lock`, so Pun and Composer can work on the same project.

- [`pun install`](/docs/commands/install), [`update`](/docs/commands/update), [`require`](/docs/commands/require), and [`remove`](/docs/commands/remove) read `composer.json` and write `composer.lock`. `require` and `remove` also edit `composer.json`.
- Commands that load the config, such as `format`, `lint`, `analyse`, and `check`, read `require.php`, `config.platform.php`, and the locked Laravel, Pest, and PHPUnit versions from the project root.

A composer.json section in `pun.toml`, such as `[require]`, `[autoload]`, or `[scripts]`, is a config error (exit 2). Put its keys in `composer.json`, and `[package]` keys at its root.

## Rule names

Rule IDs have the form `<command>/<group>/<name>`, such as `format/imports/ordered`. Inside a rules table, leave out the command: `[format.rules]` uses `"imports/ordered"`. The [rule directory](/docs/rules) lists every group and rule.

Config accepts only Pun IDs. A wrong name is an error that gives the Pun ID. `pun explain <name>` also accepts upstream names. `pun config` prints the resolved settings.

## Rule options

Option names and most values are kebab-case: PHP-CS-Fixer's `on_multiline = "ensure_fully_multiline"` is `on-multiline = "ensure-fully-multiline"`. PHP keywords such as `require_once` keep their spelling. Each [rule page](/docs/rules) lists the rule's options beside their PHP-CS-Fixer names.

TOML has no `null`. Where PHP-CS-Fixer uses `null` to leave something alone, write `"ignore"`: `"control-flow/yoda" = { less-and-greater = "ignore" }`. `types/union-spacing` uses `space-multiple-catch = "same-as-space"`. For `order` in `imports/ordered` and `validator` in `comments/header`, leave the option out.

A rule with one option that isn't a boolean or a table takes the value directly: `"arrays/syntax" = "long"` means `"arrays/syntax" = { syntax = "long" }`.

An unknown option or value is an error that lists what the rule accepts. A renamed PHP-CS-Fixer option gets its Pun name.

```text
pun.toml: `imports/ordered` has no option `sort-algorithm`: use `sort`
pun.toml: `arrays/syntax` option `syntax` = "medium": expected one of "long", "short"
```

Lint rules take their options beside `level` and `fix`: `"phpunit/require-method-casing" = { case = "snake-case" }`.

### Rules from Mago

Lint rules from Mago's linter use Mago's option names and defaults: `"complexity/no-excessive-cyclomatic" = { threshold = 20, method-threshold = 10 }`.

- Pun ignores a Mago `level` on the rule or on a `functions`, `extensions`, or `types` entry. The level comes from `pun.toml`.
- `style/require-naming-convention` replaces Mago's nine `*-name` rules. It takes one table per Mago rule, such as `method-name = { enabled = true, camel = false }`. The method, property, and variable checks are off until enabled.
- Mago's Drupal exemption for `hook_` functions in `*.api.php` files is not supported.

### Refactor rules

`refactor/*` rules do nothing until configured. They take the Rector rule's configuration:

- A map keeps its keys: `"refactor/rename-function" = { view = "Laravel\\Templating\\render" }`.
- A list of objects goes under `items`, with kebab-case properties: `"refactor/remove-function-argument" = { items = [{ function = "ldap_first_attribute", argument-position = 2 }] }`.

An invalid name, such as `"1f"` as a function name, is a config error. `refactor/rename-class` also takes `import-names` (default off), `import-short-classes` (default on), and `remove-unused-imports` (default off).

## Removed keys

Keys from earlier versions, such as a top-level `preset`, `[format] paths`, `[analyse] level`, `fix = "apply"`, or `"info"`, are config errors. Each error says what to write instead.

## Without pun.toml

Commands that load config stop with:

```text
No pun.toml found. Run `pun migrate`, or `pun init` for a new project.
```

To run without a file, pass `--preset <name>` (`laravel`, `psr12`, or `empty`) or `--no-config`, as in Pint.

## Environment variables

| Variable | Effect |
| --- | --- |
| `NO_COLOR` | Turns off colour when `--color` is `auto` |
| `COLUMNS` | Output width when Pun cannot read the terminal's |
| `CI` | `pun init` takes the defaults without asking |
| `GITHUB_ACTIONS=true` | Adds GitHub annotations after human output |
| `PUN_AGENT`, `PAO_FORCE`, `PAO_DISABLE` | Turn [agent output](/docs/guides/coding-agents) on or off |
| `PHP_CS_FIXER_IGNORE_MISMATCHED_RULES_EXCEPTIONS` | Accepts an ignore comment that names a rule the run doesn't use |
| `PUN_IGNORE_PHP_CONSTRAINT` | Runs on a project whose `require.php` allows PHP below 8.4. Unsupported: results on older syntax are unchecked |
| `PUN_PROFILE` | Prints per-stage timings on stderr |
| `PUN_CACHE_DIR` | Cache for the [result cache](/docs/commands/format#cache), Blade's Prettier workers, [`pun x`](/docs/commands/x#manage-installs) installs, and the [package store](/docs/commands/install#package-store) |
| `PUN_LINK_MODE` | How [`pun install`](/docs/commands/install#package-store) links packages from the store: `hardlink` (default), `clone`, or `copy` |
| `PUN_REQUIRE_ATTESTATION=1` | [`pun self-update`](/docs/commands/self-update) fails when it cannot check the build attestation |
| `COMPOSER_HOME`, `COMPOSER_CACHE_DIR` | Composer's home and download cache, shared with the [package commands](/docs/commands/install) |
| `COMPOSER_AUTH`, `COMPOSER_MAX_PARALLEL_HTTP` | Download credentials and parallel download limit for [`pun install`](/docs/commands/install#what-an-install-does) |
| `COMPOSER_ROOT_VERSION` | The root package's version, as in Composer |
