Hosting & Deployment

Manage PHP Runtime and Extension Compatibility

Prevent deployment surprises by checking PHP versions, required extensions and differences between CLI and web runtimes.

Overview

A PHP application can work in a terminal and fail through the website because CLI and web requests may use different PHP binaries, configuration files, extensions or versions. Production readiness requires checking the runtime that actually serves HTTP traffic.

Declare requirements

Use Composer's require.php and require.ext-* platform requirements where appropriate. Document optional extensions and application-specific configuration. A lock file records dependency versions, but it does not install missing PHP extensions.

Compare CLI and web environments

Run php -v and php -m for the CLI binary used by deployment. For the web runtime, use a temporary, access-restricted diagnostic page that reports only the information needed for verification. Remove it immediately after testing; never leave a public phpinfo() page online.

Check configuration differences

Compare memory_limit, upload limits, execution time, timezone and error logging settings. CLI jobs may use a different php.ini from PHP-FPM or Apache. Configure the correct SAPI rather than assuming one setting applies everywhere.

Test dependency compatibility

Before upgrading PHP, run the test suite and static analysis on the target version. Review deprecations and extension compatibility. Upgrade staging first and inspect application logs for warnings that may become errors in a later release.

Checklist

  • Declare PHP and extension requirements.
  • Confirm the CLI binary used by Composer and cron.
  • Verify the web SAPI separately.
  • Compare relevant php.ini values.
  • Test upgrades on staging.
  • Remove diagnostic endpoints after use.

References

PHP Configuration File · Composer Platform Dependencies

Share this page Help other developers discover this resource.