---
title: pun require
description: Add a package.
---

Add a package to `composer.json`, then install it.

## Usage

```bash
pun require <packages> [options]
```

```bash
pun require laravel/sanctum
pun require spatie/laravel-data:^4.0
pun require --dev pestphp/pest
```

## Options

| Option | Description |
| --- | --- |
| `--dev` | Add to `require-dev`. |
| `--sort-packages` | Keep the list sorted. |
| `--no-update` | Only edit `composer.json`. |
| `-p`, `--package=<member>` | Edit this [workspace](/docs/guides/workspaces) member. |

Require also takes the [`pun update`](/docs/commands/update#options) options (except `--dry-run`) and the [`pun install`](/docs/commands/install#options) options.

## What happens

- Creates `composer.json` if there is none.
- Adds the package. Without a version, writes `^major.minor` of the newest one.
- Moves the package if it is already in the other section.
- Updates and installs it, like `pun update`.
- If anything fails, restores `composer.json` and `composer.lock`.

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | Added and installed. |
| 2 | Requirements that clash, or a failed install. |
