Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

Introduction

Pun is one fast binary for your PHP toolchain, compatible with Pint, Rector, PHPStan, and Composer.

Pun is one fast binary, written in Rust, for your PHP workflow. Each command gives the same answers as the tool it replaces: Pint and PHP-CS-Fixer, Rector, PHPStan and Larastan, or Composer. You can switch one command at a time.

Pun supports projects that target PHP 8.4 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 issues 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 new project
pun install Installs the locked dependencies into vendor/, with the same 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 x (punx) Runs a command from a Composer package without adding it to the project
pun self-update Replaces pun with the latest release

Status

  • Format matches Pint on every project in the parity scoreboard. It changes layout only. Pint’s risky and code-deleting fixers are lint rules, so run pun check --fix to apply a migrated Pint config.
  • Lint and analyse cover part of Rector, PHPStan, and Larastan. The rule reference marks missing rules as Planned.
  • The package manager reads composer, package, and path repositories, and runs the Composer plugins that allow-plugins allows. It does not support vcs repositories.

PHP checks need no PHP runtime. Blade formatting needs Node.js (or Bun) and Prettier. Some config migrations need PHP and the original tool.

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, because migration can rewrite ignore comments in PHP files. Preview the migration, then run it:

pun migrate --dry-run
pun migrate

Migration skips unsupported items and warns about each one.

For a project without tool configs, run:

pun init

Neither command changes your scripts or CI configuration.

Check the project

pun check

pun 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 diff

Analysis never edits files. Lint rules with fix = "off" only report.

Check changed files

pun check --dirty
pun check --staged
pun format --diff=main

--dirty selects uncommitted changes, --staged selects files with staged changes, and --diff=main selects files changed since you branched from main.

Credits

Pun builds on Mago, PHP-CS-Fixer, Laravel Pint, PHPStan, Larastan, Rector, and Composer. Special thanks to Mago’s maintainers: Pun uses Mago’s parser and analysis libraries directly. Thank you all for sharing your work.

Last updated on

Was this page helpful?