PHP

SlowShield serves Packagist at https://slowshield.example.com/composer/, as a Composer repository that replaces packagist.org. Projects keep their composer.json as it is; only where packages come from changes.

Set it up

Two settings in Composer's global configuration cover every project on the machine: packagist.org off, and SlowShield on. One project can do the same in its own composer.json:

Composer

Release age: Composer 2.11 adds its own (config.policy.cooldown.period, measured from Packagist's published-time, which SlowShield passes on). Composer 2.10 and older have none: SlowShield is the only layer.

every project ($COMPOSER_HOME/config.json): packagist.org off, SlowShield on

composer config -g repo.packagist false && composer config -g repos.slowshield composer https://slowshield.example.com/composer/

one project's composer.json

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

a composer.lock written against packagist.org: point its dists at SlowShield (run next to it)

php -r '$l = json_decode(file_get_contents("composer.lock"), true); foreach (["packages", "packages-dev"] as $k) foreach ($l[$k] ?? [] as $i => $p) if (isset($p["dist"]["reference"])) { $l[$k][$i]["dist"]["url"] = "https://slowshield.example.com/composer/dists/{$p["name"]}/{$p["dist"]["reference"]}.{$p["dist"]["type"]}"; unset($l[$k][$i]["notification-url"]); } file_put_contents("composer.lock", json_encode($l, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n");'

What changes

Lock files

A composer.lock written through SlowShield names SlowShield in its download URLs, so installing from it goes through SlowShield too. One written against packagist.org names api.github.com, and composer install downloads from GitHub, around SlowShield, even with packagist.org off. composer update --lock doesn't change that: it only writes GitHub, GitLab and Bitbucket URLs. The last snippet above points a lock's downloads at SlowShield and changes nothing else; run it next to composer.lock once, and commit the result.

The second layer

Composer 2.11 adds a cooldown of its own, config.policy.cooldown.period, measured from the same published-time, which SlowShield passes on. Composer 2.10 and older have none, so SlowShield is the only layer.

In Docker and CI

Set the repositories in the build stage. With a build argument, the same Dockerfile still builds without SlowShield when the argument is empty:

FROM composer:2 AS vendor
ARG COMPOSER_REPO=https://slowshield.example.com/composer/
RUN if [ -n "$COMPOSER_REPO" ]; then composer config -g repo.packagist false \
      && composer config -g repos.slowshield composer "$COMPOSER_REPO"; fi
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-interaction --no-scripts --prefer-dist

In CI, run the Setup page's command before composer install. Building images covers the base image too, and how to check that nothing in a build goes around SlowShield.

Limits

For agents: this page as Markdown · llms.txt · the SlowShield skill