Skip to content

Guardrails / php

Composer dependencies are locked ​

php/lockfile-committed@v1

The project commits composer.lock, so an install of the same commit resolves the same versions.

Idphp/lockfile-committed
Versionv1
Categoryphp
Default severitywarning
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsphp

Collectors ​

This guardrail doesn't gather anything itself. It relies on the collectors below, which the CLI runs once per build before any check, and reads what they found from GUARDRAIL_FACTS. If a collector collects nothing, this guardrail is skipped, not failed.

CollectorGathersInputs it is given
phpThe Composer project in the project directory: the package it declares, the PHP version and extensions it asks for, the packages it requires and which of them are pinned, and whether the lock file is committed.projectDir

The inputs above are this guardrail's own inputs, passed straight through to the collector. Setting one in buildnote.json changes what is collected, and two guardrails configured the same way share a single collection.

Configuration ​

json
{
  "guardrails": {
      "failOn": "error",
      "checks": [
          {
              "use": "php/lockfile-committed@v1",
              "severity": "warning",
              "with": {
                  "projectDir": "."
              },
              "exemptions": []
          }
      ]
  }
}

Inputs ​

InputDescriptionDefaultEnvironment variable
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR

How to fix ​

Commit the lock file Composer writes:

bash
composer update
git add composer.lock

A ^7.0 requirement resolves to whatever the registry serves that day, so without composer.lock an application installs differently on every deploy, and the versions that shipped are not the versions that were reviewed.

More in php ​

  • php/dependencies-constrained. Every package the manifest requires has a version constraint, instead of accepting whatever the registry serves.
  • php/version-declared. The project declares the PHP version Composer resolves against, and that version is no older than the configured floor.

All 3 php guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412