---
title: Workspaces
description: Keep several packages in one repository with one lock and one vendor/.
---

A workspace holds several packages in one repository. They share one `composer.lock` and one `vendor/` at the repository root.

## Create a workspace

1. In the root `pun.toml`, list the member directories, or globs that match them:

   ```toml pun.toml
   [workspace]
   members = ["packages/*", "apps/*"]
   ```

2. Give each member a `composer.json` with a `name`:

   ```json packages/billing/composer.json
   {
       "name": "acme/billing",
       "require": {
           "acme/core": "*"
       }
   }
   ```

3. Run `pun install`.

Pun requires every member at the root and symlinks each one into `vendor/` as a path package. A member requires another member like any package, at `*` or any constraint. Put the root's own requirements and repositories in the root `composer.json`. The root needs neither a `composer.json` nor requirements of its own.

- `*` and `?` in a glob match within one directory name.
- Pun skips directories without a `composer.json`. A glob that matches nothing, such as `apps/*` before `apps/` exists, adds no member.
- A member without `name` is an error.
- Two members can't have the same name.

## Work in a member

`pun install`, `pun update`, `pun require`, and `pun remove` find the workspace from the current directory, so they work in any member. They read and write the root's `composer.lock` and `vendor/`.

`pun require` and `pun remove` edit the `composer.json` of the member you run them in, or the root's at the root. To edit another member, name it with `-p`:

```bash
pun require -p acme/billing guzzlehttp/guzzle
pun remove -p acme/billing guzzlehttp/guzzle
```

If a request doesn't resolve, the `composer.json` and the lock stay unchanged.

## Limits

- `pun install` doesn't notice when a member's requirements change outside `pun require` and `pun remove`. Run `pun update <member>` after you edit a member's `composer.json` by hand.
