Skip to content

Composer (PHP)

NORA hosts Composer packages and caches a Composer repository (Packagist by default) for Composer 2. It is off by default: set [composer] enabled = true or NORA_COMPOSER_ENABLED=true; NORA_REGISTRIES_ENABLE=all includes it. Composer 1 (the providers API) is not supported.

In composer.json:

{
"repositories": [
{ "type": "composer", "url": "https://nora.example.com/composer" },
{ "packagist.org": false }
]
}

With authentication on, give Composer a token for the registry host:

Terminal window
composer config --global http-basic.nora.example.com <user> <token>

composer audit works through NORA: it is forwarded to the upstream’s advisories API. A hosted or internal package name is never sent upstream.

The zip is the request body:

Terminal window
curl -u user:token -X PUT --data-binary @pkg.zip \
https://nora.example.com/composer/packages/upload/acme/greeter/1.0.0
  • composer.json is read from the zip root or its single top-level directory; its name must match the path’s vendor/package.
  • Versions are immutable: a second upload of the same version returns 409.
  • Branch (dev) versions are refused (400); upload a tagged release.
  • A package with an uploaded version is served only from its uploaded versions, so a package of the same name upstream cannot take it over.

config.toml:

[composer]
enabled = true
proxy = "https://repo.packagist.org"
proxy_timeout = 30
metadata_ttl = 300 # seconds
serve_stale = true

Environment variables:

VariableDescriptionDefault
NORA_COMPOSER_ENABLEDEnable the Composer registryfalse
NORA_COMPOSER_PROXYUpstream Composer repository; empty serves hosted packages onlyhttps://repo.packagist.org
NORA_COMPOSER_PROXY_AUTHUpstream auth (user:pass)—
NORA_COMPOSER_PROXIESOrdered upstreams (url|user:pass,url2); replaces proxy—
NORA_COMPOSER_PROXY_TIMEOUTUpstream timeout in seconds30
NORA_COMPOSER_METADATA_TTLSeconds a cached upstream document is served before it is revalidated300
NORA_COMPOSER_SERVE_STALEServe the cached document when the upstream failstrue
NORA_COMPOSER_REVALIDATEConditional requests for a stale documenttrue
NORA_COMPOSER_GITHUB_TOKENToken for archive downloads from api.github.com (60 anonymous requests an hour)—
NORA_COMPOSER_KEEP_SOURCEKeep a version’s source in proxied metadata when curation is offtrue

An archive is fetched only from the URL the cached upstream metadata lists for that exact version, so NORA is not an open proxy. Archives are cached permanently with a SHA-256 sidecar; the upstream’s dist.shasum is verified when it gives one.

Curation judges a package by vendor/package: the blocklist and allowlist, plus [curation.composer] for this registry (min_release_age, quarantine, quarantine_ttl; NORA_CURATION_COMPOSER_*). With curation on, proxied metadata lists only versions NORA serves an archive of, so Composer cannot fall back to cloning the source of a refused version.

  • Deleting or unpublishing a version is not implemented.
  • Search and package list endpoints are not implemented.
  • Zip64 archives are not accepted.

Full details: COMPAT.md.