pun.toml
Reference for pun.toml, Pun's config file, with paths, exclusions, extensions, presets, rule levels, and options.
pun.toml in the project root holds Pun’s settings. pun init creates it, and pun migrate converts existing configs into it. Every section is optional. Dependencies stay in composer.json.
This example uses most keys:
[php]
version = "8.4"
[files]
paths = ["app", "tests"]
exclude = ["build", "storage"]
[extensions]
laravel = "on"
pest = "on"
[format]
preset = "laravel"
exclude = ["app/Generated"]
not-path = ["app/Legacy.php"]
[format.rules]
"imports/ordered" = { sort = "length", case-sensitive = true }
"operators/concat-spacing" = "one"
"arrays/syntax" = false
[lint]
preset = "recommended"
sets = ["rector/dead-code"]
[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 |
|---|---|
preset |
At the top level: essential, recommended, or strict for every command. See one preset for every command. Each command’s own preset wins |
[php] version |
The target PHP version, as major.minor. Default: the lowest version that require.php in composer.json allows, otherwise 8.3. Rules for a newer PHP, such as the php-8.4 lint group, run only when this version allows them. Without this key, pun analyse uses config.platform.php, otherwise 8.5 |
[files] paths |
The 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.3 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. In these globs, * also matches /. For example, storage/** skips storage, not app/storage.
A plain entry is a path from the project root. Format is the exception: as in Pint, it matches a folder of that name at any depth. 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> 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. A locked package never turns an extension on by itself. pun migrate and pun init turn on each extension whose package composer.lock 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 |
carbon |
nesbot/carbon |
Carbon’s PHPStan extension in analyse: the methods that Carbon::macro() registers, and Carbon\DatePeriodBase |
| Value | Effect |
|---|---|
"on" |
On for every command |
"off", or left out |
Off |
An extension that is on lets its lint rules run: the ones your [lint] preset or [lint] sets hold. Its rules in no preset, such as laravel/no-controller-middleware, 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 set a single rule to "off".
A rule that you name in [lint.rules] runs even when its extension is off. Upgrade groups such as laravel-12 are the exception: they need the extension, and you must name them.
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 shows which extensions are on, and why.
[format]
| Key | Meaning |
|---|---|
preset |
laravel (default), psr12, or empty |
blade |
How laravel/blade formats Blade files: prettier (default) runs Prettier and prettier-plugin-blade in Node, as Pint does. native uses Pun’s built-in formatter, which needs no Node and no node_modules. It gives the same output, except that it doesn’t sort Tailwind classes |
exclude |
Added to [files] exclude for format only |
not-path |
Paths to skip, as in Pint’s notPath. PHP regular expressions work. An invalid regular expression is a run error |
not-name |
File names to skip, as in Pint’s notName, such as ["*.inc"]. Globs and PHP regular expressions work |
rules |
true, false, a table of options, or the value of the rule’s only option |
Format indents with four spaces and writes \n line endings. To change them, set the option of the rule that checks each one. Every format rule then uses it:
[format.rules]
"whitespace/indentation-type" = "tabs" # or "spaces" (default)
"whitespace/line-ending" = "crlf" # or "lf" (default)
Risky and code-deleting fixers are lint rules.
[lint]
| Key | Meaning |
|---|---|
preset |
Lint preset: essential, recommended, or strict. Each includes the ones before it. No default: without it, only sets, groups and rules run |
sets |
Rector sets to turn on, each exactly as Rector defines it: rector/dead-code, rector/php-sets, rector-laravel/laravel-code-quality, and the others |
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, which set rule levels for matching files |
Later settings win, in this order:
- The preset and sets, at
"error". - Groups.
- Rules.
- Matching overrides, in the order they appear.
-A,-W, and-Don the command line, in argument order.
Warnings don’t fail the run unless you set a warning limit. --fix skips rules with fix = "off".
Some unsafe Laravel fixes, such as laravel/prefer-request-server, write facade calls that need a booted Laravel application. Leave out code that runs before Laravel boots, such as tests/bootstrap.php, with exclude or an override.
Laravel, Pest, and PHPUnit rules also need their extension. PHP upgrade rules, such as the php-8.5 group, run only when [php] version is that version or later. 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. Or a PHPStan level preset, phpstan/level_0 to phpstan/level_10 or phpstan/level_max, which runs exactly that PHPStan level. See presets |
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 in PHPStan’s stubFiles |
scan |
Files and folders Pun reads for their classes, functions, and constants but doesn’t analyse, as in PHPStan’s scanFiles and scanDirectories |
bootstrap |
PHPStan’s bootstrapFiles. Pun doesn’t run them: it reads their symbols as scan does, and Larastan reads their macros |
bleeding-edge |
true infers types as PHPStan’s bleedingEdge.neon does, except sealed and unsealed array shapes. Default false |
union-types, nullables, explicit-mixed, implicit-mixed |
true or false turns one type switch on or off: PHPStan’s level 7, 8, 9, or 10 check. Default: on in the presets that cover that level (strict for the first two, max for all four, and each phpstan/level_<n> from its level) |
report-unmatched |
false reports no unmatched @phpstan-ignore comment and is the default of each [[analyse.ignore]] entry, as PHPStan’s reportUnmatchedIgnoredErrors. Default true |
rules |
"on", "off", or a table of options for each rule, and "on" or "off" for each group. A rule’s options are the PHPStan parameters it reads, in kebab-case; any other key, or a value of the wrong type, is a config error |
[[analyse.ignore]] |
Errors to ignore, as in 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 |
With false, Pun doesn’t report the entry when it matches nothing, as in PHPStan’s reportUnmatched. Default true |
Pun reports an entry that matches nothing, or a count that is wrong, as an error. With report-unmatched = false, Pun reports only a count that is exceeded.
[[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.
[workspace]
members = ["packages/*"]
Dependencies
Dependencies live in composer.json and composer.lock, so Pun and Composer can work on the same project.
pun install,update,require, andremovereadcomposer.jsonand writecomposer.lock.requireandremovealso editcomposer.json.- Commands that load the config, such as
format,lint,analyse, andcheck, readrequire.php,config.platform.php, and the locked Laravel, Pest, and PHPUnit versions from the project root. - Pun has no lock file of its own.
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. Put [package] keys at the root of composer.json.
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 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. For example, 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 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. For a renamed PHP-CS-Fixer option, the error gives the Pun name.
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. For example: "complexity/no-excessive-cyclomatic" = { threshold = 20, method-threshold = 10 }.
- Pun ignores a Mago
levelon the rule or on afunctions,extensions, ortypesentry. The level comes frompun.toml. style/require-naming-conventionreplaces Mago’s nine*-namerules. It takes one table per Mago rule, such asmethod-name = { enabled = true, camel = false }. The method, property, and variable checks are off until enabled.- Mago’s Drupal exemption for
hook_functions in*.api.phpfiles is not supported.
Refactor rules
refactor/* rules do nothing until you configure them. 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).
Without pun.toml
Commands that load the config stop with exit code 2 and this message:
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 color when --color is auto |
COLUMNS |
Output width when Pun cannot read the terminal’s |
CI |
Makes pun init take the defaults without asking |
GITHUB_ACTIONS=true |
Adds GitHub annotations after human output |
PUN_AGENT, PAO_FORCE, PAO_DISABLE |
Turn agent output on or off |
PUN_IGNORE_PHP_CONSTRAINT |
Runs on a project whose require.php allows PHP below 8.3. Unsupported: results on older syntax are unchecked |
PUN_PROFILE |
Prints the time of each stage on stderr |
PUN_NO_CACHE=1 |
Turns off the result cache, like --no-cache |
PUN_CACHE_DIR |
Cache for the result cache, Blade’s Prettier workers, pun x installs, and the package store |
PUN_LINK_MODE |
How pun install links packages from the store: hardlink (default), clone, or copy |
PUN_REQUIRE_ATTESTATION=1 |
pun self-update and the Composer package’s first download fail when they cannot check the build attestation |
COMPOSER_HOME, COMPOSER_CACHE_DIR |
Composer’s home and download cache, shared with the package commands |
COMPOSER_AUTH, COMPOSER_MAX_PARALLEL_HTTP |
Download credentials and parallel download limit for pun install |
COMPOSER_ROOT_VERSION |
The root package’s version, as in Composer |