Modernizing a Legacy PHP Codebase Without a Rewrite
A full rewrite is rarely approved and rarely finishes. The modernization path that actually ships runs alongside the legacy code, not instead of it.
Tanjil Ahmed
Lead Software Engineer · Notionhive
Every engineer inheriting an old PHP codebase wants to rewrite it, and almost every stakeholder is right to say no — a rewrite freezes feature work for months and has a well-documented history of never actually finishing. The modernization that works runs incrementally, alongside the business, not instead of it.
- Add a test suite around the legacy code's current behavior before changing anything — characterization tests, not aspirational ones.
- Introduce Composer and PSR-4 autoloading first, even if the rest of the code stays procedural for now.
- Wrap legacy functions behind a clean interface, then modernize the implementation behind that interface incrementally.
- Pick one vertical slice — a single feature area — to fully modernize end to end as a template before scaling the effort.
The strangler-fig approach — new code gradually replacing old code behind a stable interface, feature by feature — is slower to feel dramatic and far more likely to actually reach the finish line than a rewrite that competes with the roadmap for a year.
The fastest way to modernize legacy PHP is the one that never stops shipping features while it happens.
