Article
Composer Platform Constraints for Real Servers
Align require.php, config.platform, and extension requirements with the PHP you actually run—without using ignore-platform-reqs as a lifestyle.
Composer resolves packages for the PHP version it believes you have. If developers run PHP 8.3 locally while production FPM is 7.4, an unconstrained resolve can lock packages that never install on the server. Platform configuration exists to make that mismatch visible and intentional.
# Resolves for the developer's newer PHP; production install fails later
composer update
composer install --ignore-platform-reqs
{
"require": {
"php": "^8.1",
"ext-json": "*",
"ext-pdo": "*",
"ext-mbstring": "*"
},
"config": {
"platform": {
"php": "8.1.32"
}
}
}
require.php vs config.platform
require.php is the application’s stated supported runtime range. config.platform.php forces Composer to resolve as if that exact PHP version is present—useful so CI and laptops mimic production. Raise both when you deliberately move the runtime ladder; do not leave platform pinned to 7.4 after production is on 8.2.
Extensions are platform too
Legacy apps often need ext-gd, ext-intl, or ext-soap. Declare them so missing modules fail at install time instead of at the first request. Compare environments with PHP Environment Compare and check resolves with Composer Platform Requirement Checker.
Constraint syntax help: Version Constraint Explainer. Official docs: Composer platform config.
Related tools
- Composer.json Validator Validate composer.json structure and common mistakes without running composer install.
- Legacy PHP Risk Checker Paste PHP source for a static scan that classifies removed APIs, deprecated calls, and security-sensitive leg…
- PHP Deprecated Checker Find deprecated functions and patterns in pasted PHP to prioritize modernization work.
- PHP Environment Compare Compare two PHP environment summaries to find directive and extension mismatches.
- PHP Modernization Roadmap Build an ordered migration stage list from your PHP version, framework, Composer, database API, and deploymen…
- PHP Version Compatibility Checker Scan pasted PHP for version-sensitive syntax and APIs to plan upgrades across PHP releases.
Related reading
- Composer Modernization Center Add Composer to legacy PHP projects, migrate includes to autoloading, set platform constraints, and replace a…
- PHP 5 to Modern PHP: Complete Incremental Migration Guide A deep, production-minded path from PHP 5.x codebases to supported PHP 8.x: removed extensions, charset, PDO,…
- PHP Security Modernization for Legacy Applications Upgrade inherited PHP security practices: prepared statements, password hashing, sessions, CSRF, XSS escaping…
- PHP 7 to PHP 8 Migration Guide Deep guide to PHP 8.0 breaking changes that matter for PHP 7 applications, with upgrade tactics through suppo…
- Inheriting a Legacy PHP Application A first-30-days playbook for developers handed an unfamiliar PHP codebase: runtime truth, risk triage, and sa…