Skip to content
Esc
↑↓navigate↵open⌘Jpreview
On this page

pun require

Add packages to composer.json, then update and install.

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

pun require adds packages to require, or to require-dev with --dev, creating composer.json if needed. Then it updates those packages and their dependencies and installs them, as pun update does.

Write a package as vendor/name, vendor/name:^1.2, or vendor/name ^1.2. Without a version, Pun writes the newest version that resolves as ^major.minor. A package in the other section moves, with a warning.

If the requirements don’t resolve, nothing changes and pun require exits 2. If the install fails, Pun restores composer.json and composer.lock.

Options

Option Effect
--dev Add to require-dev
--sort-packages Keep the section sorted. Also config.sort-packages.
--no-update Edit composer.json only
-p, --package=MEMBER Edit this workspace member’s composer.json

pun require also takes the pun update options except --dry-run, and every pun install option.

Exit codes

Code When
0 Added and installed
2 Unresolvable requirements, a failed repository, or a failed install

Last updated on

Was this page helpful?