Pun: One Rust Binary to Format, Lint &amp; Analyze PHP | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com) - [Home](https://www.msaied.com)
- [Projects](https://www.msaied.com/projects)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [About](https://www.msaied.com#about)

           [  Contact](https://www.msaied.com#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com)
- [ProjectsCase studies](https://www.msaied.com/projects)
- [ArticlesEngineering notes](https://www.msaied.com/articles)
- [CertificatesCredentials](https://www.msaied.com/certificates)
- [AboutHow I work](https://www.msaied.com#about)
- [ContactGet in touch](https://www.msaied.com#contact)

  [Start a conversation](https://www.msaied.com#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com)
2. /
3. [Articles](https://www.msaied.com/articles)
4. /
5. [Laravel](https://www.msaied.com/articles?category=laravel)
6. /
7. Pun: Format, Lint, and Analyze PHP With One Rust Binary

   [Laravel](https://www.msaied.com/articles?category=laravel) [PHP](https://www.msaied.com/articles?category=php) 

 Pun: Format, Lint, and Analyze PHP With One Rust Binary
========================================================

 Pun is a single Rust binary now in public beta that replaces Laravel Pint, PHP-CS-Fixer, Rector, PHPStan, Larastan, and Composer — all configured through one pun.toml file.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com#person) Published 26 Nov 2026 · Updated 28 Nov 2026 · 4 min read

ShareCopy linkCopied

 ![Pun: Format, Lint, and Analyze PHP With One Rust Binary](https://cdn.msaied.com/837/a736608b65db9fe102769f6c2479bef1.png) 

  On this page +1. [What Is Pun?](#what-is-pun)
2. [Core Commands](#core-commands)
3. [Formatting](#formatting)
4. [Linting](#linting)
5. [Static Analysis](#static-analysis)
6. [Running Everything at Once](#running-everything-at-once)
7. [Package Management](#package-management)
8. [Migrating From Existing Tools](#migrating-from-existing-tools)
9. [Laravel-Specific Support](#laravel-specific-support)
10. [Current Beta Limitations](#current-beta-limitations)
11. [Key Takeaways](#key-takeaways)

 What Is Pun?
------------

[Pun](https://github.com/shipfastlabs/pun) is a single Rust binary, now in public beta, that consolidates PHP formatting, linting, static analysis, and package management into one tool. According to the [documentation](https://punphp.com/docs), it is designed to replace Laravel Pint, PHP-CS-Fixer, Rector, PHPStan, Larastan, and Composer. All configuration lives in a single `pun.toml` file, and the `format`, `lint`, and `analyse` commands do not require PHP to be installed on the machine.

Pun targets projects running PHP 8.3 or later and builds on the parser and analysis libraries from [Mago](https://laravel-news.com/mago), porting rules and test fixtures from the tools it replaces.

Core Commands
-------------

### Formatting

`pun format` fixes layout, casing, and spelling, producing output that matches Laravel Pint byte-for-byte. To check without modifying files, use the `--test` flag:

```bash
pun format --test

```

### Linting

`pun lint` reports code that could be written better. Three presets are available — `essential`, `recommended`, and `strict` — and `pun lint --fix` applies the suggested changes automatically.

### Static Analysis

`pun analyse` reports type errors such as calls to undefined methods, similar to PHPStan. It never modifies files. You can snapshot the current error state for incremental cleanup:

```bash
pun analyse --generate-baseline

```

### Running Everything at Once

`pun check` runs format, lint, and analyse together. The `--fix` flag applies all auto-fixable issues in one pass. You can also scope the check to only the files you have touched:

```bash
pun check --dirty    # uncommitted changes
pun check --staged   # staged files
pun check --diff=main # files changed since branching from main

```

Every command exits with `0` (clean), `1` (problems found), or `2` (Pun could not run).

### Package Management

`pun install` reads `composer.json` and `composer.lock`, downloads packages in parallel, verifies checksums, and links them into `vendor/` from a shared local store. `pun require`, `pun update`, and `pun remove` handle the usual Composer lifecycle.

Migrating From Existing Tools
-----------------------------

`pun migrate` reads your `pint.json`, `.php-cs-fixer.php`, `rector.php`, and `phpstan.neon` files and writes a single `pun.toml`. Preview the result before committing:

```bash
pun migrate --dry-run
pun migrate

```

Migration rewrites `@phpstan-ignore` and `@php-cs-fixer-ignore` comments to `@pun-ignore`, so the docs recommend starting from a clean Git working tree. PHPStan baselines are not carried over — generate a new one with `pun analyse --generate-baseline`. Pint's `symfony` preset and custom Rector closures are not supported.

For a fresh project, `pun init` asks which presets you want and writes the file. A typical Laravel + Pest setup looks like this:

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

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

[format]
preset = "laravel"

[lint]
preset = "recommended"

[analyse]
preset = "recommended"

```

Laravel-Specific Support
------------------------

When `pun migrate` or `pun init` detects Laravel, Pest, or PHPUnit in `composer.lock`, it enables the corresponding extensions automatically. With the `laravel` extension active, `pun analyse` runs Larastan checks without a separate install, and `pun lint` adds Laravel-specific rules such as `laravel/no-request-all`.

Because Pun does not execute PHP, it discovers macros by reading `X::macro()` and `X::mixin()` calls in service providers and bootstrap files. Macros with computed names or those registered by vendor files may be missed.

The package also ships a [Laravel Boost](https://github.com/laravel/boost) guideline that instructs coding agents (Claude Code, Cursor, Codex) to run `pun check --fix --dirty` after editing PHP files.

Current Beta Limitations
------------------------

- Not every Rector, PHP-CS-Fixer, PHPStan, or Larastan rule is implemented yet; missing ones are marked **Planned** in the rule reference.
- A format rule Pun does not implement is treated as a config error, and Pun exits before touching any file.
- `pun install` does not support custom installer paths (e.g., `composer/installers`) or packages locked to a VCS-only source.
- Blade formatting requires Node.js with Prettier unless you set `blade = "native"`.

Key Takeaways
-------------

- One binary replaces Pint, PHP-CS-Fixer, Rector, PHPStan, Larastan, and Composer.
- No PHP installation needed for format, lint, or analyse commands.
- `pun migrate` converts existing configs to `pun.toml` in a single step.
- Built-in Laravel and Pest extension support, including Larastan checks.
- Currently in public beta; some rules and Composer features are still planned.

---

*Source: [Laravel News — Pun: Format, Lint, and Analyze PHP With One Rust Binary](https://laravel-news.com/pun-php-toolchain)*

- [PHP](https://www.msaied.com/articles?search=PHP)
- [Laravel](https://www.msaied.com/articles?search=Laravel)
- [Rust](https://www.msaied.com/articles?search=Rust)
- [Static Analysis](https://www.msaied.com/articles?search=Static%20Analysis)
- [Code Quality](https://www.msaied.com/articles?search=Code%20Quality)
- [Tooling](https://www.msaied.com/articles?search=Tooling)

 Frequently asked questions 
---------------------------

  Does Pun require PHP to be installed on the machine?No. The format, lint, and analyse commands do not require PHP to be installed. Only package management commands that interact with Composer packages need the project's PHP dependencies.

   How do I migrate an existing Laravel project from Pint, PHPStan, and Rector to Pun?Run `pun migrate --dry-run` to preview the changes, then `pun migrate` to generate a `pun.toml` from your existing `pint.json`, `phpstan.neon`, and `rector.php` files. Start from a clean Git working tree because Pun rewrites ignore comments in your PHP files. PHPStan baselines are not migrated automatically — create a new one with `pun analyse --generate-baseline`.

   What are the known limitations of Pun's package management compared to Composer?During the public beta, `pun install` does not support custom installer paths such as those provided by `composer/installers`, and packages that are locked to a VCS-only source will fail to install.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous articleLaravel Black Friday and Cyber Monday Deals 2026](https://www.msaied.com/articles/laravel-black-friday-and-cyber-monday-deals-2026)  

   On this page
-------------

1. [What Is Pun?](#what-is-pun)
2. [Core Commands](#core-commands)
3. [Formatting](#formatting)
4. [Linting](#linting)
5. [Static Analysis](#static-analysis)
6. [Running Everything at Once](#running-everything-at-once)
7. [Package Management](#package-management)
8. [Migrating From Existing Tools](#migrating-from-existing-tools)
9. [Laravel-Specific Support](#laravel-specific-support)
10. [Current Beta Limitations](#current-beta-limitations)
11. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/834/bd4177ac22f4bab6c85e743e4f0051e6.png) Laravel · 3 min read### Laravel Black Friday and Cyber Monday Deals 2026

23 Nov 2026 ](https://www.msaied.com/articles/laravel-black-friday-and-cyber-monday-deals-2026) [ ![](https://cdn.msaied.com/836/db1492ae4c7344b53fc65bb37075cf40.png) Laravel · 4 min read### Laravel Suspicious Login: Detect and Block Risky Logins with Risk Scoring

23 Nov 2026 ](https://www.msaied.com/articles/laravel-suspicious-login-detect-and-block-risky-logins-with-risk-scoring) [ ![](https://cdn.msaied.com/835/85710585fb2cbe5fd3fbf12fe76c647b.png) Laravel · 4 min read### Decide with Jev Episode 5: Make Failed AI Requests Safe in Laravel

22 Nov 2026 ](https://www.msaied.com/articles/decide-with-jev-episode-5-make-failed-ai-requests-safe-in-laravel) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com)
- [Articles](https://www.msaied.com/articles)
- [Certificates](https://www.msaied.com/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/sitemap.xml)
