---
title: Introduction
description: 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`](/docs/commands/format) | Fixes layout, casing, and spelling, as Pint and PHP-CS-Fixer do |
| [`pun lint`](/docs/commands/lint) | Reports code problems and fixes them with `--fix`, as Rector, Mago, and PHP-CS-Fixer's risky fixers do |
| [`pun analyse`](/docs/commands/analyse) | Reports type errors without editing files, as PHPStan and Larastan do |
| [`pun check`](/docs/commands/check) | Runs format, lint, and analyse in one pass |
| [`pun migrate`](/docs/commands/migrate) | Converts your Pint, PHP-CS-Fixer, Rector, and PHPStan configs to `pun.toml` |
| [`pun init`](/docs/commands/init) | Creates `pun.toml` for a project without those configs |
| [`pun install`](/docs/commands/install) | Installs the locked dependencies into `vendor/`, with the files Composer writes |
| [`pun update`](/docs/commands/update) | Resolves the dependencies again and writes the lock Composer writes |
| [`pun require`](/docs/commands/require), [`pun remove`](/docs/commands/remove) | Adds or removes packages, then updates and installs |
| [`pun composer dump-autoload`](/docs/commands/composer) | Writes the autoloader again |
| [`pun x`](/docs/commands/x) (`punx`) | Runs a command from a Composer package without adding it to the project |
| [`pun self-update`](/docs/commands/self-update) | Replaces `pun` with the latest release |

To inspect a project, use [`pun config`](/docs/commands/config), [`pun list-files`](/docs/commands/list-files), [`pun extension list`](/docs/commands/extension), and [`pun explain`](/docs/commands/explain).

## Get started

[Install Pun](/docs/installation), then run these commands from your project root.

1. **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:

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

    Migration skips unsupported items and warns about each one.

    For a project without tool configs, run:

    ```bash
    pun init
    ```

    Neither command changes your scripts or CI configuration.

2. **Check the project**

    ```bash
    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.

3. **Apply fixes**

    ```bash
    pun check --fix
    git diff
    ```

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

4. **Check changed files**

    ```bash
    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](/docs/configuration/pun-toml)**

Paths, exclusions, rules, and options.

**[Migration](/docs/commands/migrate)**

Supported configs and migration limits.

**[CI](/docs/guides/ci)**

Run Pun on every push.

## Credits

Pun builds on [Mago](https://github.com/carthage-software/mago), [PHP-CS-Fixer](https://github.com/PHP-CS-Fixer/PHP-CS-Fixer), [Laravel Pint](https://github.com/laravel/pint), [PHPStan](https://github.com/phpstan/phpstan), [Larastan](https://github.com/larastan/larastan), [Rector](https://github.com/rectorphp/rector), and [Composer](https://github.com/composer/composer). Pun uses Mago's parser and analysis libraries directly. Thank you to everyone behind these projects for sharing your work.
