Safeguard
Developer Tools•

Composer platform config vs platform-check: what is the difference?

The platform setting fakes PHP and extension versions during resolution. platform-check verifies the real runtime. Why you want both, and a deploy test.

Safeguard Security Team
3 min read

The platform setting tells Composer to pretend your PHP version and extensions are something specific while it resolves packages. The platform-check setting makes the generated autoloader verify the real runtime. One shapes what gets installed, the other catches a mismatch at runtime.

What each setting does

SettingPurposeDefault
platformFake PHP and extension versions for resolutionEmpty, uses the real machine
platform-checkCreate a check file that verifies the runtimephp-only

The Composer docs describe platform as letting you fake platform packages. Setting an extension to false hides a locally installed extension from Composer. They add a caveat: dependencies are then no longer checked accurately, so running check-platform-reqs is recommended.

For platform-check, the default checks only the PHP version. Setting it to true also checks that extensions are present. Setting it to false stops Composer creating the platform_check.php file at all.

Why this is a security topic

Platform settings decide which package versions can be chosen. If your lock file was resolved against PHP 8.3 but production runs an older, unsupported PHP, you may be running dependency versions that were never tested together, on a runtime that no longer gets fixes. Pinning the platform to your real production version keeps resolution honest.

Steps to configure it well

  1. Set the platform PHP version to match production, not the newest on your laptop.
  2. Keep platform-check on at least php-only. Consider true if extensions matter to you.
  3. Before each deploy, run the platform requirements check against the lock file.
  4. Fail the build when it reports a mismatch.
composer check-platform-reqs --lock --no-dev

The lock option checks requirements from composer.lock rather than from installed packages. The docs also note that this command ignores your platform config, which is the point: it tests the real requirements, not the pretend ones.

Common mistakes

  • Faking a newer PHP version to make an install pass, then running older PHP in production.
  • Turning platform-check off to silence an error, which removes the safety net.
  • Checking only on a developer machine, which may have extra extensions installed.

Try it yourself

Click through it at your own pace, or open it full screen. Watch how drift between the inventory and the running system gets flagged.

Where Safeguard fits

Safeguard's policies and gates can check dependency changes in a pull request before merge. A free scan shows what it finds today.

Quick check

Does platform-check slow down my application?

Composer generates a small check file that runs at autoload time. If you want to skip it, the setting can be false, but then you lose the runtime guard.

Should the platform setting match production?

Yes. Otherwise the lock file may contain versions chosen for a runtime you do not use.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.