Skip to content
Scalpels home

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

Documentation

Crate

Connecting your apps

Updated

Crate is a provider: your other applications install packages from it. What authenticates is Composer, during composer install or composer update, so any PHP project with a composer.json can use Crate. The artisan-build/crate-client package is a convenience for Laravel applications that writes Composer's auth file from two environment values.

Attach an application through Scalpels

For an application your team runs on Laravel Cloud or Laravel Forge, attach it to your Crate from Scalpels. The steps, requirements and refusals are in Attach to an existing app.

For Crate, attaching:

  • issues a registry credential on your Crate for that application;
  • writes CRATE_URL (your Crate's address) and CRATE_TOKEN (the credential) into the application's environment;
  • opens a draft pull request that adds your Crate installation as the named crate Composer repository, adds artisan-build/crate-client at ^0.2 to composer.json, adds CRATE_URL and an empty CRATE_TOKEN to .env.example, and adds /auth.json to .gitignore.

Scalpels never shows you the credential and never merges the pull request.

Finish the pull request

Check out the pull request's branch. The pull request already adds the named crate Composer repository at your Crate installation's URL, so you do not need to run composer config repositories.crate yourself.

Run the composer update command shown in the pull request, commit composer.lock, then review and merge.

crate-client requires PHP 8.3 or newer and Laravel 13.

Give Composer the credential

With CRATE_URL and CRATE_TOKEN in the environment, write Composer's auth:

php artisan crate:auth

This writes or merges an http-basic entry for your Crate's host into auth.json in the current directory, with the username token and CRATE_TOKEN as the password. Other entries in the file are kept. Use --path=/somewhere/auth.json to write elsewhere.

For CI or a build step, print the JSON instead and pass it to Composer through COMPOSER_AUTH:

export COMPOSER_AUTH="$(php artisan crate:auth --print)"

Do not run --print anywhere its output is kept, such as an agent tool call or a logged CI step, because it contains the credential. Never commit auth.json.

If CRATE_URL or CRATE_TOKEN is missing, or CRATE_URL has no valid host, crate:auth reports the error and exits unsuccessfully.

Connecting by hand

For a Laravel application hosted somewhere other than Laravel Cloud or Laravel Forge, you do by hand what attaching would have done. Apps hosted somewhere else covers the general steps. For Crate:

  1. Get a credential. Either open your Crate from the Scalpels dashboard, choose the Other tab and select Generate credentials, or create a registry credential under Settings on your Crate (see Credentials).

  2. Add your Crate as the crate Composer repository and install the client:

    composer config repositories.crate composer https://crate.example.com
    composer require artisan-build/crate-client:^0.2
    
  3. Set these variables wherever the application keeps its environment. CRATE_URL is your Crate's address with no path.

    CRATE_URL=https://crate.example.com
    CRATE_TOKEN=the-token-you-were-shown-once
    
  4. Make sure /auth.json is in .gitignore. Laravel's skeleton already has that line.

  5. Give Composer the credential wherever it installs your private packages, as above: php artisan crate:auth on a machine that keeps its files, or COMPOSER_AUTH in a build step.

To commit placeholders, add CRATE_URL= and CRATE_TOKEN= to .env.example, with the token left blank.

Without the client package

Any Composer project can use Crate with two commands and a credential from Settings on your Crate (see Credentials):

composer config repositories.crate composer https://crate.example.com
composer config --auth http-basic.crate.example.com token "<credential>"

Verify the connection

Pick a package your Crate serves, then from the application's directory:

php artisan crate:auth
composer show vendor/private-package --all

A working connection exits with status 0 and prints the package's name and versions. Then composer require vendor/private-package installs it as usual.

A 401 means Composer reached Crate but the credential was not accepted: it is missing, wrong, revoked, or not a registry credential. Crate does not say which. See Troubleshooting.