Free 20-minute strategy call with a senior engineer: AI, payments, eLearning or custom software
Engineering

Migrating from PHP 7.4 to PHP 8: Breaking Changes and Upgrade Guide

PHP: Migrating from PHP 7.4.x to PHP 8.0.x

In short

Migrate from PHP 7.4 to PHP 8.x: the real PHP 8.0 breaking changes, later 8.x deprecations, support dates, Rector, PHPCompatibility and an upgrade plan.

PHP 7.4 reached end of life in November 2022 and PHP 8.0 in November 2023, so applications still on 7.4 no longer receive security fixes. This guide explains how to migrate from PHP 7.4 to PHP 8: the real breaking changes in PHP 8.0, the later 8.x changes to plan for, the tools that automate most of the work, and a step-by-step upgrade process.

Quick answer: don’t stop at PHP 8.0, which is no longer supported. Upgrade from 7.4 to a supported release (PHP 8.3 or 8.4 for most projects). Update dependencies first, run PHPCompatibility, Rector and PHPStan to find and fix issues, test thoroughly on a staging server, then deploy.

PHP version support status

VersionReleasedSecurity support endsStatus
PHP 7.4Nov 2019Nov 2022End of life
PHP 8.0Nov 2020Nov 2023End of life
PHP 8.1Nov 2021Dec 2025End of life
PHP 8.2Dec 2022Dec 2026Security fixes only
PHP 8.3Nov 2023Dec 2027Supported
PHP 8.4Nov 2024Dec 2028Supported
PHP 8.5Nov 2025Dec 2029Supported

Check php.net/supported-versions for the current schedule. Read why running unsupported versions is risky in our article on how outdated PHP versions affect WordPress sites.

What’s new in PHP 8.0

  • JIT compiler: can speed up CPU-heavy code (most web apps see smaller gains than from PHP 7’s improvements).
  • Named arguments: str_pad(string: $s, length: 10, pad_string: '-').
  • Union types: function load(int|string $id).
  • Nullsafe operator: $user?->getAddress()?->city.
  • Match expression: a stricter, expression-based alternative to switch.
  • Constructor property promotion: declare and assign properties in the constructor signature.
  • Attributes: native metadata such as #[Route('/users')] instead of docblock annotations.
  • New functions: str_contains(), str_starts_with(), str_ends_with().

Breaking changes in PHP 8.0 to check

These are the changes most likely to break PHP 7.4 code:

  1. String to number comparisons changed. 0 == "foo" is now false (it was true). Comparisons between numbers and non-numeric strings now compare as strings.
  2. Internal functions throw TypeError and ValueError instead of returning null with a warning when given invalid arguments.
  3. Many warnings became Error exceptions, for example using an undefined constant, writing to a property of a non-object, or arithmetic on arrays and objects. Undefined variables and array keys now raise warnings instead of notices.
  4. Removed functions and features: create_function(), each(), money_format(), the (unset) cast, $php_errormsg and track_errors, and curly-brace string offsets such as $str{0}.
  5. Resources became objects: GD images are now GdImage, cURL handles are CurlHandle, and so on, so is_resource() checks on these fail.
  6. The @ operator no longer silences fatal errors, and the default error_reporting is now E_ALL, so hidden problems may appear.
  7. Parameter names matter because of named arguments; renaming a parameter in a library is now a potential breaking change.
  8. Stricter method signature checks for inherited and abstract methods cause fatal errors instead of warnings.
  9. Unparenthesised nested ternaries (deprecated in 7.4) are now a compile error: $a ? $b : ($c ? $d : $e).

Note: PHP 8 does not make return types mandatory or enable strict_types by default. Type checking only becomes strict in files that declare declare(strict_types=1);.

Free resource

Upgrade and patching checklist

Want this applied to your project? Our engineers will send it with notes for your stack.

Get it free

Changes in PHP 8.1 to 8.5 to plan for

If you are jumping from 7.4 to a current release, also review:

  • PHP 8.1: passing null to non-nullable parameters of internal functions is deprecated (a very common warning in older code). Adds enums, readonly properties, fibers and never return type.
  • PHP 8.2: dynamic properties are deprecated unless the class allows them with #[AllowDynamicProperties]. Adds readonly classes and standalone true, false and null types.
  • PHP 8.3: typed class constants, json_validate() and the #[\Override] attribute.
  • PHP 8.4: property hooks, asymmetric visibility and new array functions; implicitly nullable parameter types (Type $x = null) are deprecated.
  • PHP 8.5: the pipe operator (|>) and other improvements.

Always read the official migration guides at php.net/manual/en/appendices.php for each version you skip.

Tools that make PHP upgrades faster

ToolWhat it does
PHPCompatibility (for PHP_CodeSniffer)Scans code for features removed or changed in your target PHP version
RectorAutomatically rewrites code for newer PHP versions and frameworks
PHPStan or PsalmStatic analysis that catches type errors and undefined code paths
Composercomposer why-not php 8.3 shows which dependencies block the upgrade
PHPUnit or PestAutomated tests to confirm behaviour is unchanged

Step-by-step migration from PHP 7.4 to PHP 8

  1. Back up your code and database, and keep the current server configuration documented.
  2. Set up a development or staging environment that mirrors production, running the target PHP version.
  3. Update dependencies. Upgrade Composer packages, your framework (for example Laravel, Symfony or CodeIgniter) and CMS plugins to versions that support the target PHP version.
  4. Scan your code with PHPCompatibility and PHPStan to list incompatibilities.
  5. Run Rector with the PHP 8 rule sets to fix common issues automatically, then review the changes.
  6. Fix remaining issues by hand: string comparisons, removed functions, resource checks, null arguments and dynamic properties.
  7. Turn on all errors and deprecations in development and fix the warnings, not just the fatal errors.
  8. Test thoroughly: automated tests, manual testing of key journeys (login, checkout, forms, reports), cron jobs and integrations.
  9. Check server extensions and settings: make sure required extensions are installed and php.ini settings are carried over. Enable OPcache.
  10. Deploy and monitor. Deploy during a quiet period, keep the old PHP version available for a quick rollback, and watch error logs closely.

Migration tips

  • Upgrade one major step at a time in testing (7.4 → 8.0 → 8.1 …) if the codebase is large, even if you deploy straight to the final version.
  • Watch for unmaintained libraries; replace them rather than patching them indefinitely.
  • On shared hosting or cPanel, you can usually switch versions per site with MultiPHP Manager after testing.
  • Budget time for deprecation clean-up so the next upgrade is easier.

Frequently asked questions

Is it safe to upgrade directly from PHP 7.4 to PHP 8.3 or 8.4? Yes, if you test properly. Review the breaking changes for every version in between, and use Rector and static analysis to catch issues.

What breaks most often when upgrading to PHP 8? String-to-number comparisons, removed functions such as each() and create_function(), stricter errors from internal functions, outdated dependencies and, in PHP 8.1 and 8.2, null argument and dynamic property deprecations.

Is PHP 8 faster than PHP 7.4? Generally yes. Each PHP 8 release brings performance improvements, and the JIT helps CPU-intensive tasks.

How long does a PHP 8 migration take? From a few days for a small, well-tested application to several weeks for a large legacy codebase with many dependencies.

Need help with your PHP upgrade?

Vibidsoft Pvt Ltd upgrades legacy PHP applications to supported PHP 8 releases, including compatibility audits, Rector-assisted refactoring, framework upgrades, testing and deployment. See our PHP development services or contact us for an assessment.

Vibidsoft Engineering Team

Senior engineers who have shipped 450+ projects since 2014 across AI, payments, eCommerce, eLearning and custom software. Every guide is written and reviewed by the people who do the work.

Follow us on LinkedIn · About Vibidsoft

Next step

Talk to an engineer about Modernize & Rescue

Fixed-price upgrades for ageing PHP, Drupal, Magento or hybrid apps, with security patching and a care plan. from $5,000.

  • A 20-minute call with a senior engineer, not a salesperson
  • A written next-step plan within one business day
  • NDA on request

See our PHP development and upgrades service

Book a call WhatsApp