Introduction
Pun is one Rust binary that formats, lints, and analyses PHP 8.3+ projects and installs their Composer packages.
Pun is one Rust binary for your PHP toolchain. It replaces Pint, PHP-CS-Fixer, Rector, PHPStan, Larastan, and Composer, and gives the same answers as each. Switch one command at a time. It supports projects that target PHP 8.3 or later.
Commands
| Command | What it does |
|---|---|
pun format |
Fixes layout, casing, and spelling, as Pint and PHP-CS-Fixer do |
pun lint |
Reports code problems and fixes them with --fix, as Rector, Mago, and PHP-CS-Fixer’s risky fixers do |
pun analyse |
Reports type errors without editing files, as PHPStan and Larastan do |
pun check |
Runs format, lint, and analyse in one pass |
pun migrate |
Converts your Pint, PHP-CS-Fixer, Rector, and PHPStan configs to pun.toml |
pun init |
Creates pun.toml for a project without those configs |
pun install |
Installs the locked dependencies into vendor/, with the files Composer writes |
pun update |
Resolves the dependencies again and writes the lock Composer writes |
pun require, pun remove |
Adds or removes packages, then updates and installs |
pun composer dump-autoload |
Writes the autoloader again |
pun x (punx) |
Runs a command from a Composer package without adding it to the project |
pun self-update |
Replaces pun with the latest release |
To inspect a project, use pun config, pun list-files, pun extension list, and pun explain.
Get started
Install Pun, then run these commands from your project root.
Create pun.toml
If you have a Pint, PHP-CS-Fixer, Rector, or PHPStan config, start from a clean Git working tree. Migration can rewrite ignore comments in PHP files. Preview the migration, then run it:
pun migrate --dry-run
pun migrateMigration skips unsupported items and warns about each one.
For a project without tool configs, run:
pun initNeither command changes your scripts or CI configuration.
Check the project
pun checkpun check reports format, lint, and analysis findings without editing files. It exits 0 when clean, 1 on findings, and 2 when Pun could not run.
Apply fixes
pun check --fix
git diffAnalysis never edits files. Lint rules with fix = "off" only report.
Check changed files
pun check --dirty
pun check --staged
pun check --diff=main--dirty selects files with uncommitted changes. --staged selects files with staged changes. --diff=main selects files changed since you branched from main.
Configuration
Paths, exclusions, rules, and options.
Migration
Supported configs and migration limits.
CI
Run Pun on every push.
Credits
Pun builds on Mago, PHP-CS-Fixer, Laravel Pint, PHPStan, Larastan, Rector, and Composer. Pun uses Mago’s parser and analysis libraries directly. Thank you to everyone behind these projects for sharing your work.