---
title: pun x
description: Run a command from a Composer package without adding it to the project.
---

```bash
punx laravel new example-app
punx phpstan:^2.1 analyse src
punx friendsofphp/php-cs-fixer fix --dry-run
pun x squizlabs/php_codesniffer phpcbf src
```

`pun x` installs a package into Pun's cache and runs its command in the current directory. Your project's `composer.json`, `composer.lock`, and `vendor/` stay untouched. `punx` is an alias that the installer adds.

The first run installs the newest stable release. A later run checks for a new release once a day, and falls back to the installed version offline. The command's output and exit code are its own. Pun's progress goes to stderr.

## Name the package

Write `vendor/name`, or `vendor/name:^1.2` to pin a version. Each constraint gets its own install. These short names also work:

| Name | Package |
| --- | --- |
| `laravel` | `laravel/installer` |
| `pint` | `laravel/pint` |
| `envoy` | `laravel/envoy` |
| `phpstan` | `phpstan/phpstan` |
| `psalm` | `vimeo/psalm` |
| `rector` | `rector/rector` |
| `php-cs-fixer` | `friendsofphp/php-cs-fixer` |
| `phpcs`, `phpcbf` | `squizlabs/php_codesniffer` |
| `phpunit` | `phpunit/phpunit` |
| `pest` | `pestphp/pest` |
| `phpmd` | `phpmd/phpmd` |

## Pick the command

Pun picks the first of the package's `bin` files that matches:

1. The first argument, as in `pun x squizlabs/php_codesniffer phpcbf`. The rest go to that command.
2. The short name, such as `phpcbf`.
3. The package's only command.
4. The command named after the package, such as `phpstan`.

If none matches, `pun x` lists the commands and exits 2.

## Manage installs

```bash
punx list
punx clean phpstan
punx clean phpstan:^2.1
punx clean
```

`punx list` prints each install and its version:

```text
laravel/installer     v5.24.2
phpstan/phpstan:^2.1  2.1.40
```

`punx clean` removes every install, every version of a named package, or one constraint's install.

Installs live in `$PUN_CACHE_DIR/x`. The default cache is `~/.cache/pun` (or `$XDG_CACHE_HOME/pun`) on Linux and `~/Library/Caches/pun` on macOS.

## Exit codes

| Code | When |
| --- | --- |
| The command's | The command ran |
| 0 | `list` or `clean` finished |
| 2 | The package didn't resolve or install, or it has no command to run |
