Architecture, modernization and mentoring · Guide
How do you migrate from PHP 5 to PHP 8 without downtime?
Migrating from PHP 5 to PHP 8 without downtime means upgrading the system in steps, version by version, with tests that pin down current behavior before each one. The code is adjusted to run on both the current version and the next, and every cutover has acceptance criteria and a rollback plan.
Master TimmUpdated on 5 min read
On this page
Why PHP 5 and PHP 7 are a risk today
Under the project's current policy, every PHP version gets two years of active support and two more of security fixes only. After that, new flaws are no longer fixed.
- PHP 5.6: End of life on December 31, 2018.
- PHP 7.4, the last 7.x release: End of life on November 28, 2022.
- PHP 8.0 and 8.1: End of life on November 26, 2023 and on December 31, 2025.
- Supported in October 2026: 8.2, with security fixes only until December 31, 2026, plus 8.3, 8.4 and 8.5.
The risk goes beyond security: new libraries stop accepting old versions, servers and hosting providers stop offering them, and every year without an upgrade makes the jump bigger.
What breaks between PHP 5 and PHP 8
The migration guides in the PHP manual list the incompatible changes of every version. In old systems, these are the ones that show up most.
- Extensions removed in PHP 7.0: Mysql, mssql and ereg are gone; database access moves to mysqli or PDO, and regular expressions to the preg functions.
- PHP 4-style constructors: In PHP 8.0, a method named after the class is no longer a constructor, and the code has to use __construct().
- Functions removed in PHP 8.0: Each() and create_function() are gone, replaced by foreach and anonymous functions.
- Comparisons: In PHP 8.0, 0 == "foo" becomes false, which changes the outcome of if and switch statements in old code.
- Warnings turned into errors: In PHP 8.0, count() on a value that is not countable throws a TypeError and stops execution.
- Recent deprecations: Passing null to parameters of built-in functions (8.1) and creating dynamic properties (8.2) raise notices that announce future breaks.
A test safety net before touching the code
Legacy systems rarely have tests, so the migration starts with them. The goal is not to cover everything: it is to pin down the behavior the business cannot lose.
- Characterization tests: They record what the system does today, right or wrong, on the most used routes and rules.
- End-to-end critical flows: Orders, invoicing, payments and whatever else operations use every day.
- Static analysis: Compatibility tools point out removed functions and syntax that will not run on the target version.
- A reproducible environment: The same Docker container for the team and for CI, with the current and the next version side by side.
On a legacy PHP and React/TypeScript platform at Quilt Software / PosNation, we took the Jest test suite from 540 to 1,455 in 3 weeks, with CI and pre-commit gates.
Upgrading version by version, and cutting over without downtime
- Inventory: Versions, extensions, libraries, integrations and whatever runs on cron or in a queue.
- Code compatible with both versions: Every fix runs on the current version and the next, so it ships to production before PHP is switched.
- Dependencies and framework: Libraries and the framework move up together when the old version does not run on the target PHP.
- Staging with real data: The new version runs in parallel, with the tests and the critical flows passing.
- Cutover: Traffic moves gradually to servers on the new version, with acceptance criteria and the way back ready.
- Next version: Once the current one is stable in production, the cycle starts again.
At Regal Rexnord (NYSE: RRX), we took critical applications from PHP 5.6 to 8.4, across 10 versions, and moved two systems from CodeIgniter 2 to 3, with unit-test suites for zero-downtime cutovers.
Where AI helps in the migration, and where it does not
- It helps to read: AI coding agents such as Claude Code read undocumented code, map dependencies and explain hidden business rules.
- It helps to write: It proposes characterization tests and the repetitive fixes of each version, such as replacing removed functions.
- It does not decide: Recovered business rules are validated by people who know the operation, and every merge goes through human review.
- It does not replace tests: An AI-generated change goes in only with an approved spec and the suite passing.
At Regal Rexnord, we used Claude Code to reverse-engineer undocumented legacy code, in the same engagement that took the applications from PHP 5.6 to 8.4.
Related service
Legacy Modernization
Modernize legacy systems without stopping operations.
Free first conversation · Reply within 1 business day
See also: AI Software Automation.
Frequently asked questions
Can you jump straight from PHP 5.6 to PHP 8?
You can switch PHP in fewer steps, but the changes of every version along the way still apply and have to be fixed. That is why the code moves version by version, and the server switches only when the suite passes on the target version. The bigger the single jump, the riskier each cutover.
Can the framework be upgraded along with PHP?
Yes, and it is often necessary, because old framework versions tend not to support new PHP versions. The safe path alternates the two, one jump at a time, each with its own tests and cutover, as with the two systems we moved from CodeIgniter 2 to 3 at Regal Rexnord.
Is new feature work frozen during the migration?
It does not have to be: since every fix runs on both versions, migrated code and new features go through the same pipeline, with the same tests. What needs coordination is the window of each cutover, kept short and agreed with operations.
Is PHP 7.4 still safe in production?
Not from the PHP project: version 7.4 stopped receiving fixes, security ones included, on November 28, 2022. Some Linux distributions and vendors keep their own patches for longer, but new libraries already require PHP 8, and the jump grows every year.
Sources
Master Timm · Updated on