Skip to content
Scalpels home

Sign up now for $10 in credit on a new Laravel Cloud account.

Documentation

Crate

Serving packages

Updated

Crate serves the repositories you register with it. The list lives in Crate's database, so adding or removing a package never needs a redeploy. Every change queues a Satis build, and the build writes Composer metadata and zip archives to your bucket.

Let your agent add packages

The easiest way to add a package is to ask your agent, for example "Serve github.com/acme/private-package from my Crate." The agent runs Crate's commands for you through the Laravel Cloud CLI. It needs the CLI installed on your machine and signed in to your Cloud account. These are the steps it follows.

  1. Check the Cloud CLI. Run cloud --version. If the CLI is missing, install it with composer global require laravel/cloud-cli. If it is not signed in, run cloud auth, which opens your browser so you can approve it.

  2. Find Crate's environment. Run cloud app:list to find the Crate application, then cloud env:list <application> to list its environments. An environment is one running copy of the application, usually main. Every Crate command below needs its ID. If there is more than one Crate, ask which one to use.

  3. Read the package name. Use the name from the repository's composer.json, for example with gh api repos/acme/private-package/contents/composer.json -H "Accept: application/vnd.github.raw". Crate only builds a package under its real name.

  4. Check whether the repository is private. Run gh repo view acme/private-package --json visibility. A public repository needs no source token, so skip to step 6.

  5. Get a read-only source token without putting it in the chat. Give the person a link that opens GitHub's new token form already filled in, with their owner and repository in it:

    https://github.com/settings/personal-access-tokens/new?name=Crate+acme%2Fprivate-package&description=Read+access+for+Crate+builds&target_name=acme&contents=read
    

    They choose the repository under Repository access, generate the token, and copy it. Crate keeps one token per host, so if Crate already serves other private repositories from GitHub, they should select those too. The agent never asks for the token in the chat and never prints it. It reads the token from the clipboard in the next step instead.

  6. Register the repository. On macOS, $(pbpaste) inserts the copied token. On Linux, use $(wl-paste) or $(xclip -o -selection clipboard). Leave out --source-token for a public repository.

    cloud command:run <environment-id> --cmd="php artisan crate:repos:add acme/private-package https://github.com/acme/private-package.git --source-token=$(pbpaste)" -n
    
  7. Wait for the build. Check with crate:repos:list, or with the build_history MCP tool. The status moves from pending to building, then to active. If it ends as failed, see Troubleshooting.

  8. Use the package. The composer_repository MCP tool returns the composer.json entry and the composer require command for a project. For the person's own machine, send them to Connect this machine in Crate. For CI, use create_project_credential. See Credentials.

To remove a package, the agent runs crate:repos:remove the same way. To change a token, it removes the repository and adds it again with the new token.

The rest of this page covers the same commands in detail, for when you want to run them yourself.

Running Crate's commands

Crate's commands run wherever you type them. On Laravel Cloud, run them in your environment through Cloud's command runner, for example:

cloud command:run <environment-id> --cmd="php artisan crate:repos:list" -n

The examples below show only the php artisan ... part.

Register a repository

php artisan crate:repos:add vendor/package https://github.com/vendor/package.git
  • The name must be a lowercase vendor/package: letters, numbers, dots, underscores and hyphens. Crate lowercases what you type.
  • Use the package's real name from its composer.json. The build asks Satis for that name from the repository you gave, so a different name builds nothing.
  • --type sets the Satis repository type: vcs (the default), git or path. vcs is right for GitHub and other Git hosts.
  • Registering a name that already exists fails with The repository [vendor/package] already exists.

On success Crate prints Added repository [vendor/package]. and queues a build for that package.

Private repositories and source tokens

Add --source-token=<token> when the repository is private:

php artisan crate:repos:add vendor/package https://github.com/vendor/package.git --source-token=<token>

Crate stores the token encrypted and uses it only during builds. For github.com it is passed to Composer as a GitHub OAuth token; for any other host it is sent as a bearer token. Use a read-only, narrowly scoped token you can revoke. For GitHub, a fine-grained token with read access to the repository's contents and metadata is enough.

Crate keeps one token per host. If several repositories on the same host have different tokens, a build uses only one of them, so give every repository on a host a token that can read all of them, or store the token on one repository only.

crate:repos:list never prints tokens, and neither do Crate's API or MCP tools; they only say whether a repository has one.

List and remove

php artisan crate:repos:list
php artisan crate:repos:remove vendor/package

The list shows each repository's name, URL, type, status and the time it was last built. Removing a repository queues a full build, which also deletes that package's archives from your bucket.

Repository status

Status Meaning
pending Registered, not built yet.
building A build that includes it is running.
active The last build that included it succeeded.
failed The last build that included it failed.

A full build covers every repository, so one failing repository marks all of them failed until the next successful build. Packages that were already built keep being served from the bucket in the meantime.

When builds run

  • When you add a repository, or replace or clear its source token: a build of that one package.
  • When you remove a repository: a full build.
  • When you run php artisan crate:build (full) or php artisan crate:build vendor/package (one package).
  • Once a day, from the scheduler: a full build.
  • When an agent asks for one through the trigger_build MCP tool. See Agents.

Pushing a new tag to a repository does not trigger a build. Run crate:build vendor/package when you want a release available before the daily rebuild.

Builds run one at a time on the queue. crate:build only queues the job and prints Dispatched Crate Satis build.; the result shows up in the repository status and the build history.

What a build produces

Crate generates the Satis configuration from the database on every build. It serves only the packages you registered, without their dependencies; your projects still resolve public dependencies from Packagist. Every branch and tag is archived as a zip, including development branches.

The output is written to the bucket under the satis prefix and served at /packages.json, /p2/... and /dist/... behind the credential check described in Credentials. Archive links point at your Crate, never at the bucket.

Each build record keeps the last 10,000 characters of the Satis output, with source tokens replaced by ***. Neither the HTTP endpoints nor the MCP tools return that output.

Managing repositories over HTTP

Signed-in users can also manage repositories through JSON endpoints that use the browser session (with Laravel's CSRF token on writes):

Request Who
GET /crate/repositories Any active member
POST /crate/repositories with name, url, optional type and source_credential Owners and Admins
DELETE /crate/repositories/{name} Owners and Admins
PUT /crate/repositories/{name}/source-credential with source_credential Any active member
DELETE /crate/repositories/{name}/source-credential Any active member
GET /crate/builds Any active member

The Artisan commands have no way to change a token on an existing repository. Use the source-credential endpoints, or remove the repository and add it again with the new token.