Skip to content
Latchkey

Composer platform_check.php "requires php >= X" fatal in CI

Composer writes vendor/composer/platform_check.php, which runs at autoload time and aborts with a clear message if the running PHP is below what your locked dependencies need. This fires at runtime, not during install.

What this error means

A script, test, or web request dies immediately with "Composer detected issues in your platform: Your Composer dependencies require a PHP version >= 8.2.0. You are running 8.1.27." before your code executes.

php
PHP Fatal error:  Composer detected issues in your platform:
Your Composer dependencies require a PHP version ">= 8.2.0". You are running 8.1.27.
in /home/runner/work/app/app/vendor/composer/platform_check.php on line 24

Common causes

vendor was built for a newer PHP than the runner runs

The lock was resolved against PHP 8.2+, but the job step runs an older PHP, so the platform check fails before your code starts.

A split between the install PHP and the run PHP

composer install ran on one PHP version and the application runs on another older one in a later step or container.

How to fix it

Run on the PHP version your lock requires

Provision the same (or newer) PHP for the run step that the dependencies were locked against.

.github/workflows/ci.yml
- uses: shivammathur/setup-php@v2
  with:
    php-version: '8.2'

Keep install and run PHP consistent

  1. Use the same PHP version for the composer install step and the run/test steps.
  2. In multi-container setups, match the PHP image used to build vendor and to run.
  3. Re-run once both use the required PHP.

How to prevent it

  • Pin one PHP version across install, build, and run steps.
  • Match container PHP images to the version vendor was locked against.
  • Test on the lowest PHP version you intend to support.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →