Article

Migrating from PHP 7.4 to PHP 8

Focused upgrade notes for the common PHP 7.4 production baseline moving onto PHP 8.x.

PHP 7.4 was the last PHP 7 release line and remains a frequent production pin. It already forbids many PHP 5 APIs, so the remaining work is mostly the PHP 8.0 engine breakages plus later 8.1/8.2 deprecations. Read migration80 alongside the deep 7→8 guide.

7.4-specific prep

  • Enable notices in staging on 7.4 now—many 8.0 fatals warn earlier.
  • Replace remaining each() / create_function() while still on 7.4 (deprecated since 7.2).
  • Confirm typed properties and covariance changes already match your subclasses.
  • Lock dependencies that claim php: ^7.4|^8.0 and test the 8.x side explicitly.
# LEGACY still common on 7.4
$fn = create_function('$x', 'return $x * 2;');

# MODERN
$fn = static fn($x) => $x * 2;

First production target

Boot on 8.1+ in CI, then choose a supported minor (8.2–8.5). Use the checklist as the deploy gate and scanners before cutover.

Related scanners: PHP Version Compatibility Checker · PHP Deprecated Checker.

Related reading