Troubleshoot Composer platform requirements using the actual CLI and web PHP environments rather than forcing incompatible dependencies.
Symptoms: what this problem looks like
- A deployment fails with a Composer platform_check.php message.
- composer install works on a developer laptop but production throws a version or extension error.
- The PHP CLI version differs from the web-serving PHP-FPM version.
Why it happens
- The runtime PHP version is older than the lockfile requires.
- Required extensions such as intl, mbstring or zip are absent in one environment.
- A different php executable is used by CI or the web server.
- Packages were installed ignoring platform requirements, hiding a real incompatibility.
Before making changes
Capture the original error and its exact time. Work on an authorized system, keep sensitive details out of public logs, and preserve a restorable configuration or data backup whenever a change could affect production.
- Capture the exact required PHP constraint or extension name from the error.
- Identify the PHP version from the failing execution environment, not a different shell.
- Confirm which Composer lockfile and release directory are actually deployed.
Choose Beginner for low-risk recovery checks or Advanced for environment-specific commands and evidence-based changes. Always confirm the underlying cause. Record the first unsatisfied package platform constraint. An extension mismatch and a PHP version mismatch require different solutions. Check the PHP version selected by the hosting dashboard and application environment. Shared hosting may use different CLI binaries and web handlers. Choose an appropriate supported PHP runtime or restore the last compatible lockfile. Treat composer.lock as a release artifact. Run tests with the same PHP runtime and extensions used on production; redeploy atomically where possible. These commands read package and runtime requirements; run them in the project root without changing dependencies. Use the executable path and the server process configuration to identify which PHP is actually running. Only after matching requirements, perform a normal locked install in staging or CI. Do not use --ignore-platform-reqs to force deployment.
Step-by-Step Troubleshooting
Read the requirement rather than bypassing it
Compare CLI with hosting runtime
Install compatible dependencies on staging
Deploy a verified combination
Check locked platform requirements
php -vphp -mcomposer check-platform-reqsCheck the selected CLI runtime
command -v phpphp --inicomposer --versionRebuild for a supported runtime
composer install --no-interaction --prefer-dist --no-devcomposer check-platform-reqs
Common mistakes to avoid
- Do not edit vendor/composer/platform_check.php to conceal the mismatch.
- Do not disable required security or runtime extensions indiscriminately.
- Do not update all dependency versions in production without lockfile review and staging tests.
How to verify the fix
Retest the original failing path or operation, not only a generic homepage or status code. Compare the result against your pre-change evidence and observe the system long enough to rule out a temporary recovery.
- The target runtime satisfies composer check-platform-reqs.
- The actual web application loads without platform check errors.
- Smoke tests pass with the release lockfile and intended PHP handler.
Solution Checklist
If the error continues: rollback and escalation
If the platform change fails, restore the last compatible runtime and lockfile-backed release; do not roll back a database migration blindly.
If you need vendor or hosting support, share the software version, exact time, affected route, sanitized error and the single change already attempted. Never include passwords, private tokens, raw session cookies or personal data.
Prevent this issue from returning
- Pin the PHP runtime and required extensions in CI and hosting configuration.
- Validate composer check-platform-reqs before deploying the artifact.
Further reading
Consult the official or primary technical documentation for your exact software version before changing production settings.
This troubleshooting guide presents possible causes and safe diagnostic steps. Product versions, hosting restrictions and deployment procedures vary; a recognized symptom is not a confirmed root cause.