SBOM for PHP products under the CRA

Composer keeps production and development packages apart in `composer.lock`, which makes PHP one of the cleaner ecosystems for an SBOM. This page shows the commands and what sits outside Composer's view.

By NormavioUpdated

Build the SBOM from composer.lock: it pins every package and keeps development ones in a separate packages-dev section, so leaving them out is reliable. Use the official CycloneDX Composer plugin or any lockfile-based generator, and check vulnerabilities with composer audit. What Composer doesn't record is the PHP runtime and its extensions: if you ship those, they need an SBOM too.

Which file the SBOM comes from

Package managerFileFull dependency tree?Dev dependencies left out?
Composercomposer.lockYesYes: the packages-dev section

How to generate it

With the CRA Starter Kit tool

normavio_sbom.py reads composer.lock, skips vendor, leaves out packages-dev, and writes a readable report for the technical file next to the SBOM.

python3 normavio_sbom.py ./shop-module \
    --name "Nimbus Shop module" --version 2.0.0 \
    --osv --out ./technical-file/sbom/2.0.0
# -> sbom.cdx.json and sbom-report.md

With the official CycloneDX plugin

The plugin adds a Composer command that writes the SBOM from your project.

composer require --dev cyclonedx/cyclonedx-php-composer
composer CycloneDX:make-sbom --output-format=JSON --output-file=sbom.cdx.json

Check vulnerabilities

Since Composer 2.4, composer audit checks the lock against the PHP security advisories database. Add --no-dev to look only at what you ship.

composer audit --no-dev

What catches teams out

  • The PHP runtime and extensions. ext-* requirements and PHP itself aren't packages in composer.lock. If you ship them (a Docker image, an appliance, a hosted build), scan the image as well.
  • Plugins for WordPress, Magento, PrestaShop… If you sell a plugin with its vendor folder bundled, those packages are components you ship. The composer.lock you built that vendor from is the source of the SBOM; don't scan the host CMS.
  • Version prefixes. Composer versions often start with v (v6.4.1). The kit's tool strips it so the package URL matches vulnerability databases.
  • Forks and VCS repositories. Packages installed from a Git fork keep the original name in the lock. Say in the report which ones are forks, because public advisories may not apply, or may apply without a fix.

What the CRA asks of this SBOM

  • Identify and document the components, including by drawing up an SBOM in a commonly used, machine-readable format, covering at least the top-level dependencies (Annex I, Part II, point 1).
  • Keep it in the technical documentation, one per product version (Annex VII, point 2).
  • Use it to find and fix vulnerabilities in those components without delay (Annex I, Part II, point 2).

The SBOM guide covers formats, fields and how to keep it alive.

Frequently asked questions

Do I include packages-dev?

No, if they aren't installed in what you ship (composer install --no-dev). The CRA SBOM documents the components of the product placed on the market.

Does a SaaS PHP application need a CRA SBOM?

Generally not if it is only offered as a service: pure SaaS is usually outside the CRA. It does if you also sell an installable version or a plugin. See the scope guide.

Is composer.json enough?

No. It holds constraints such as ^6.4, not the versions you shipped. Commit and use composer.lock.