• 7 min read

Migrating to Pun: Move Pint, Rector, and PHPStan Into One pun.toml

Move a Laravel project from Pint, Rector, and PHPStan to Pun. See what pun migrate converts, what it skips, and how to roll it out safely in CI.

Featured image for "Migrating to Pun: Move Pint, Rector, and PHPStan Into One pun.toml"

Pun is the new single-binary PHP toolchain, now in public beta. It formats, lints, and analyses PHP, installs Composer packages, and keeps its settings in one pun.toml file. If you want the general tour, I wrote one on the PHP Architect blog last week.

This post is about the next step: taking a real Laravel project that already runs Pint, Rector, and PHPStan (or Larastan) and moving it over without losing a day to it. The pun migrate command does most of the work, but it does not move everything, and a few of the gaps are easy to miss.

Where Pun stands today

A quick reality check before you touch a config file. According to the project README, Pun targets projects on PHP 8.3 or later, formats code byte for byte like Laravel Pint, and uses Mago’s parser and analysis libraries under the hood. Versions run from v0.1.0-beta.1 to v0.4.0 as of November 24, 2026, so this is pre-1.0 software.

That shapes the whole plan below. You are not ripping out your current tools on day one. You are running Pun next to them until you trust it.

Step 1: install it as a dev dependency

There is a standalone installer, but for a team project the Composer package keeps the version pinned in composer.lock with everything else:

git switch -c try-pun
composer require --dev shipfastlabs/pun

The binary lands at vendor/bin/pun. The format, lint, and analyse commands do not need PHP installed to run, per the Laravel News write-up.

Step 2: preview the migration

pun migrate reads your pint.json, .php-cs-fixer.php, rector.php, and phpstan.neon files and writes one pun.toml. Preview it first:

vendor/bin/pun migrate --dry-run

Read that output closely. Pun prints every rule it could not move, and that list is your to-do list for the rest of the migration.

Then check your working tree before you run it for real:

git status
vendor/bin/pun migrate

The clean tree matters because of one behavior that is easy to overlook. Migration leaves your old config files and composer.json alone, but it does rewrite @phpstan-ignore and @php-cs-fixer-ignore comments in your PHP files to @pun-ignore. That is a source code change spread across however many files carry ignore comments. You want it in its own commit where you can review it or revert it.

Step 3: handle what migration skips

Three things do not come across, as documented in the Laravel News coverage:

  1. PHPStan baselines are not copied. You generate a new one.
  2. Pint’s symfony preset is not supported. Migration stops with an error.
  3. Custom rules and closures are skipped with a warning.

The baseline is the one most legacy projects will hit. Create a fresh one:

vendor/bin/pun analyse --generate-baseline

Expect the new baseline to differ from your PHPStan one. Pun does not yet implement every PHPStan or Larastan rule, so the count will not match line for line. If you want to pin the analysis to a specific PHPStan level’s rule set, the analyse preset accepts values such as phpstan/level_5.

If you rely on custom PHPStan rules or Rector closures, those keep living in the original tool for now. This is the strongest argument for running both side by side for a while.

What the resulting pun.toml looks like

On a Laravel app with Pest, the generated config from pun init looks like this (example from Laravel News):

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

[files]
exclude = ["tmp", "temp"]

[format]
preset = "laravel"

[lint]
preset = "recommended"

[analyse]
preset = "recommended"

Both pun migrate and pun init turn on the laravel, pest, and phpunit extensions when they find those packages in composer.lock. With the laravel extension on, pun analyse runs Larastan’s checks without a separate install, and pun lint adds Laravel rules such as laravel/no-request-all.

When you are unsure what Pun actually resolved, pun config prints the final configuration and pun explain describes a rule along with its upstream names.

The Laravel macro caveat

Larastan boots your application to learn about it. Pun does not run PHP at all. It finds macros by reading X::macro() and X::mixin() calls in your service providers and bootstrap files.

The docs list the cases this misses, including macros with computed names and macros registered by other vendor files. If your codebase leans on macros from third-party packages, expect some undefined method reports from pun analyse that Larastan never raised. Check those before you decide your code is broken.

Step 4: run both toolchains side by side

Here is how I would wire it into CI during the trial. This is my suggestion, not something from the Pun docs. Keep your existing checks as the gate, and add Pun as a job that is allowed to fail:

jobs:
  quality:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: composer install --no-interaction
      - run: vendor/bin/pint --test
      - run: vendor/bin/phpstan analyse

  pun-trial:
    runs-on: ubuntu-latest
    continue-on-error: true
    steps:
      - uses: actions/checkout@v4
      - run: composer install --no-interaction
      - run: vendor/bin/pun check

pun check runs format, lint, and analyse together. Every Pun command exits with 0 when the run is clean, 1 when it finds problems, and 2 when Pun could not run, so the job fails the way you would expect once you remove continue-on-error.

For the formatter specifically, there is a quick local test of the “byte for byte like Pint” claim. Run Pint, commit, then ask Pun whether it would change anything:

vendor/bin/pint
git commit -am "Pint pass"
vendor/bin/pun format --test

pun format --test checks files without changing them. A clean exit on your own codebase tells you more than any benchmark.

Step 5: speed up the local loop

Pun can limit a run to the files you touched:

vendor/bin/pun check --dirty
vendor/bin/pun check --staged
vendor/bin/pun check --diff=main

--dirty covers uncommitted changes, --staged covers staged files, and --diff=main covers files changed since you branched from main. The staged option fits a pre-commit hook. A minimal .git/hooks/pre-commit would be:

#!/bin/sh
vendor/bin/pun check --staged

Make it executable with chmod +x. A non-zero exit code blocks the commit.

Coding agents get compact output

If you work with Claude Code, two details are worth knowing. The Composer package includes a Laravel Boost guideline that tells a coding agent to run pun check --fix --dirty after it edits PHP. And when Pun detects Claude Code, Cursor, or Codex, it prints one summary line and one line per problem instead of the full human-readable report.

If your project does not use Boost, you can get the same habit with one line in CLAUDE.md:

After editing any PHP file, run `vendor/bin/pun check --fix --dirty` and fix what it reports.

Beta limits to check before you commit

From the Laravel News list of current limitations:

  • Pun does not have every Rector, PHP-CS-Fixer, PHPStan, or Larastan rule yet. The rule reference marks missing ones as Planned.
  • A format rule Pun does not implement is a config error, and Pun exits before it edits any file. That is a safe failure, but it means a migrated config may need trimming.
  • pun install does not support custom installer paths such as composer/installers, and a package locked with only a VCS source fails.
  • Blade formatting needs Node.js with Prettier unless you set blade = "native".

I would leave composer install in place for now and adopt the quality commands first. They are the lower-risk half, because you can diff their results against tools you already trust.

When to delete the old configs

My rule of thumb: once pun format --test has been clean against Pint for a couple of weeks, the trial CI job has stopped surprising you, and nothing on your skipped-rules list is something you depend on, make pun check the gate and remove pint.json, phpstan.neon, and the old dev dependencies in a single pull request. Until then, the old files cost you nothing by sitting there.

Sources