Languages

SBOMs for PHP and Composer

Composer has no built-in SBOM command. sbombox generate detects composer.json and uses cdxgen or syft. The CycloneDX Composer plugin is the do-it-yourself option.

At a glance

PHP and SBOMBox
Package managerBuilt-in SBOM commandWhat sbombox generate runsLockfile to commit
ComposerNo (CycloneDX Composer plugin)cdxgen, then syftcomposer.lock

Generate with SBOMBox

curl -fsSL https://sbombox.com/install.sh | sh

sbombox generate -o sbom.json
sbombox score sbom.json

cdxgen separates required packages from packages-dev in composer.lock. Install it with the CLI:

curl -fsSL https://sbombox.com/install.sh | SBOMBOX_GENERATORS=syft,cdxgen sh

To pin the choice, set SBOMBOX_GENERATOR to one or more generator names, comma-separated. SBOMBox tries them in that order and skips any that are not installed. An unknown name fails with the list of valid names.

SBOMBOX_GENERATOR=cdxgen sbombox generate -o sbom.json

Use the CycloneDX Composer plugin

--omit=dev leaves dev packages out. Without --output-file, the plugin writes to stdout.

composer require --dev cyclonedx/cyclonedx-php-composer
composer CycloneDX:make-sbom --output-format=JSON --omit=dev --output-file=sbom.json
# See what lowers the score
sbombox score sbom.json --format detailed

# Check a ruleset, e.g. EU Cyber Resilience Act readiness
sbombox compliance sbom.json -p cra-readiness

# Upload it to the active project, labelled with the release
sbombox push sbom.json --version v1.4.0

Monorepos

Known gaps

Troubleshooting

Common PHP issues
SymptomCauseFix
No lockfile for composer: transitive dependencies may be missing and versions may be guessed.composer.lock not committedRun composer install, commit composer.lock
No SBOM generator found for ecosystems [...]. Install one with: curl -fsSL https://sbombox.com/install.sh | shNeither cdxgen nor syft is installedRun curl -fsSL https://sbombox.com/install.sh | sh
PHPUnit in the SBOMDev packages includedUse the Composer plugin with --omit=dev, or cdxgen

In CI, run the same commands. See GitHub Actions, GitLab CI, Jenkins, Azure Pipelines, Bitbucket Pipelines or CircleCI, or use the GitHub Action.