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
| Version | Released | Security support ends | Status |
|---|---|---|---|
| PHP 7.4 | Nov 2019 | Nov 2022 | End of life |
| PHP 8.0 | Nov 2020 | Nov 2023 | End of life |
| PHP 8.1 | Nov 2021 | Dec 2025 | End of life |
| PHP 8.2 | Dec 2022 | Dec 2026 | Security fixes only |
| PHP 8.3 | Nov 2023 | Dec 2027 | Supported |
| PHP 8.4 | Nov 2024 | Dec 2028 | Supported |
| PHP 8.5 | Nov 2025 | Dec 2029 | Supported |
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:
- String to number comparisons changed.
0 == "foo"is nowfalse(it wastrue). Comparisons between numbers and non-numeric strings now compare as strings. - Internal functions throw
TypeErrorandValueErrorinstead of returningnullwith a warning when given invalid arguments. - Many warnings became
Errorexceptions, 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. - Removed functions and features:
create_function(),each(),money_format(), the(unset)cast,$php_errormsgandtrack_errors, and curly-brace string offsets such as$str{0}. - Resources became objects: GD images are now
GdImage, cURL handles areCurlHandle, and so on, sois_resource()checks on these fail. - The
@operator no longer silences fatal errors, and the defaulterror_reportingis nowE_ALL, so hidden problems may appear. - Parameter names matter because of named arguments; renaming a parameter in a library is now a potential breaking change.
- Stricter method signature checks for inherited and abstract methods cause fatal errors instead of warnings.
- 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.
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
nullto non-nullable parameters of internal functions is deprecated (a very common warning in older code). Adds enums, readonly properties, fibers andneverreturn type. - PHP 8.2: dynamic properties are deprecated unless the class allows them with
#[AllowDynamicProperties]. Adds readonly classes and standalonetrue,falseandnulltypes. - 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
| Tool | What it does |
|---|---|
| PHPCompatibility (for PHP_CodeSniffer) | Scans code for features removed or changed in your target PHP version |
| Rector | Automatically rewrites code for newer PHP versions and frameworks |
| PHPStan or Psalm | Static analysis that catches type errors and undefined code paths |
| Composer | composer why-not php 8.3 shows which dependencies block the upgrade |
| PHPUnit or Pest | Automated tests to confirm behaviour is unchanged |
Step-by-step migration from PHP 7.4 to PHP 8
- Back up your code and database, and keep the current server configuration documented.
- Set up a development or staging environment that mirrors production, running the target PHP version.
- Update dependencies. Upgrade Composer packages, your framework (for example Laravel, Symfony or CodeIgniter) and CMS plugins to versions that support the target PHP version.
- Scan your code with PHPCompatibility and PHPStan to list incompatibilities.
- Run Rector with the PHP 8 rule sets to fix common issues automatically, then review the changes.
- Fix remaining issues by hand: string comparisons, removed functions, resource checks,
nullarguments and dynamic properties. - Turn on all errors and deprecations in development and fix the warnings, not just the fatal errors.
- Test thoroughly: automated tests, manual testing of key journeys (login, checkout, forms, reports), cron jobs and integrations.
- Check server extensions and settings: make sure required extensions are installed and
php.inisettings are carried over. Enable OPcache. - 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.
