Upgrading the PHP version: inventory, testing and a fallback plan
Installing a new PHP version takes minutes. Finding out whether the application still does what it should afterwards takes longer — and that work decides whether the switch is a quiet appointment or an outage.
What you will learn
In short
Split the upgrade into two steps. First, adapt the code so that it runs on the old and the new PHP version, and deploy it in that form. Only then switch the runtime. Because the code tolerates both versions, the way back is a matter of switching the version back rather than an emergency repair under time pressure.
Three checks sit in between: an inventory of the environment (extensions, libraries, configuration, background processes), a static analysis of the code against the target version, and a test run on an environment that matches production. The target version follows from the PHP project’s support list and from whether your dependencies are ready.
Which versions are supported in October 2026
The PHP project maintains each release branch for four years: two years of full support, during which reported bugs and security issues are fixed in regular point releases, followed by two years of fixes for critical security issues only, released as needed. After that, support ends. The status according to php.net on 24 October 2026:
| Version | Released | Active support until | Security fixes until |
|---|---|---|---|
| PHP 8.5 | 20 November 2025 | 31 December 2027 | 31 December 2029 |
| PHP 8.4 | 21 November 2024 | 31 December 2026 | 31 December 2028 |
| PHP 8.3 | 23 November 2023 | 31 December 2025 (ended) | 31 December 2027 |
| PHP 8.2 | 8 December 2022 | 31 December 2024 (ended) | 31 December 2026 |
| PHP 8.1 and older | — | ended | ended (PHP 8.1 on 31 December 2025) |
Two dates fall within the next few weeks: on 31 December 2026, security support for PHP 8.2 ends, and on the same day PHP 8.4 moves into the phase in which only security issues are fixed. An application on PHP 8.2 or older should therefore be scheduled now, not in January.
A sensible target is the newest version that all your dependencies officially support — in October 2026 usually PHP 8.4 or 8.5. If the libraries are not ready for 8.5 yet, 8.4, with security fixes until the end of 2028, is a sound intermediate target. Some Linux distributions and hosting providers maintain their own PHP packages for longer. That is a commitment from that provider, not from the PHP project, and it should be in writing.
Inventory: what the new version can affect
A PHP upgrade does not only concern the source code. Many surprises come from the environment. A careful inventory looks at five things:
The result is a list of findings and decisions, not a guess. How such a review begins for an application you are taking over is described in Taking over existing PHP software.
Finding outdated code before users do
Three kinds of tools help to fill the list from the code itself. None of them replaces a test run, but each finds places that a test only hits by chance.
What static tools miss, PHP reports itself at runtime, as a notice of level E_DEPRECATED. Many production configurations do not log these notices. During testing, they should therefore be collected explicitly. An example with two typical leftovers:
<?php
// Old code that still runs, but newer PHP versions complain about it.
function formatInvoice(DateTimeInterface $date = null): string
{
return ($date ?? new DateTimeImmutable('2026-10-24'))->format('d.m.Y');
}
function isPaid(mixed $value): bool
{
return (boolean) $value;
}null because its default value is null, and the long form (boolean) of a type cast.<?php
declare(strict_types=1);
// Collect deprecation notices instead of hiding them,
// e.g. while the test suite runs against the new PHP version.
$found = [];
set_error_handler(function (int $no, string $msg, string $file, int $line) use (&$found): bool {
$found[] = sprintf('%s:%d %s', basename($file), $line, $msg);
return true; // handled, do not print
}, E_DEPRECATED | E_USER_DEPRECATED);
require __DIR__ . '/legacy.php';
echo formatInvoice(), ' ', var_export(isPaid(1), true), PHP_EOL;
echo 'PHP ', PHP_VERSION, ': ', count($found), ' deprecation(s)', PHP_EOL;
foreach ($found as $entry) {
echo ' ', $entry, PHP_EOL;
}0 deprecation(s). PHP 8.4 reports the implicitly nullable parameter, and PHP 8.5 additionally reports the non-canonical cast (boolean). The fix — ?DateTimeInterface $date = null and (bool) — runs on all three versions without a notice. That is exactly the version that gets deployed before the switch.A hypothetical example
The cron job that was left behind
A company runs a customer portal on PHP 8.2. Its hosting provider moves the website to PHP 8.4 as planned, the tests pass, the portal works. Three days later, someone notices that no orders have reached the inventory system since the switch.
The cause: the nightly export runs as a cron job through a hard-coded path to the command-line PHP. That installation was never switched, and a library that came with the last update now requires a newer version. The job aborts, writes its error to a log file nobody reads, and otherwise stays silent.
The inventory would have found this with a single question: which processes start PHP, and with which binary? Add monitoring that checks not only whether the site responds, but whether the export has run since yesterday. How errors in such processes become visible is covered in Error handling and logging.
Testing and a trial run on the target version
Existing automated tests run on the new version first, with deprecation notices switched on. Where tests are missing, start with the processes whose failure someone would notice: login, creating an order, generating an invoice, data export, sending e-mail, file upload. Why a test only proves something when it checks concrete cases is explained in the article on software testing.
Next comes a trial run on a test environment that matches production: the same extensions, the same configuration, the same cron jobs and a recent copy of the data prepared for testing. Interfaces to other systems are tested there against their test accounts, not the live ones. Where several PHP versions are installed side by side, as many server control panels allow, the test environment can be switched per site without touching the rest of the server.
Once the error log stays quiet for a few days and the background processes have each completed at least one full run, the application is ready for the switch.
Switchover and fallback plan
The fallback plan is written before the switch — with names and criteria, not as an intention.
- Deploy code for both versions. The changes go live while the old PHP version is still running. In Composer, the
config.platform.phpsetting keeps dependencies at a level both versions can carry. - Choose the moment. Outside peak hours, but with people available — not on the Friday evening before a holiday.
- Switch. Web server, command line and workers together, following the list from the inventory.
- Observe. The error log, the business-critical processes checked by hand, and the background processes on their first run.
- Decide. Criteria agreed in advance state when to switch back, and a named person makes the call.
Because the code runs on both versions, the way back consists of resetting the PHP version, not rolling back code. Only once the new version has run stably for an agreed period is the platform setting raised, and the code may then use features that exist only in the new version. From that moment there is no simple way back, which is why it is a deliberate step.
If you run an application that has grown over the years and cannot judge how far it is from a supported version, that is a typical starting point for PHP modernisation.
Common misconceptions
Further sources
- PHP: Supported Versions support periods of maintained versions
- PHP: Unsupported Branches versions without support, with end dates
- PHP: Migrating from PHP 8.3.x to PHP 8.4.x official migration guide, including removed extensions
- PHP: Migrating from PHP 8.4.x to PHP 8.5.x official migration guide
- PHPCompatibility: PHP Compatibility check for PHP_CodeSniffer rule set and testVersion
- Config Reference | PHPStan the phpVersion parameter
- Rector Documentation: PHP Refactoring and Upgrade Guide automated refactoring, preview with --dry-run
About the author
Fabian Lücker is managing partner of PHP Schmiede KG in Rheine and has worked in software development since 2007. He is responsible for development and design, and writes here about decisions that come up in real projects.
Is your application running on an older PHP version?
Tell us the current version, the environment and the most important processes. We will explain what an inventory for the upgrade involves.