Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
PHP Development

Improving Old Code Without a Rewrite

Last updated:

Rewrites usually fail

A rewrite has to reach feature parity with a system that has absorbed years of business rules, edge cases and undocumented behaviour, while the original keeps changing.

The rewrite that takes eighteen months and is abandoned at eighty per cent complete is a genuinely common outcome, and it costs more than the problem it was meant to solve.

The order that works

  1. Get onto a supported PHP version — security first
  2. Get it into version control, if it is not already
  3. Add a staging environment, so changes can be tested
  4. Write tests around the parts that matter most
  5. Then improve incrementally, module by module

Version upgrade first

An application running an unsupported PHP version receives no security fixes. That is the most urgent problem in most legacy applications and it is frequently the easiest to address.

Compatibility checking tools identify what needs changing, and the work is usually smaller than expected for applications that were reasonably written.

Tests before changes

  • Test the paths that carry money or customer data first
  • Characterisation tests — capture what it currently does, not what it should
  • Cover the reports and calculations people rely on
  • Do not aim for complete coverage; aim for confidence in the important parts

Tests written around existing behaviour let you change code without discovering the consequences in production.

Strangle rather than replace

New functionality goes into a modern structure alongside the old code, and old functionality moves across piece by piece as it needs changing anyway.

Over a year or two the system modernises without ever being unavailable and without a single high-risk cutover.

Frequently asked questions

How long does modernisation take?

The version upgrade is usually weeks. Full modernisation is a year or more of incremental work alongside normal development.

When is a rewrite justified?

When the business rules have genuinely changed, or when the original is so poor that understanding it costs more than replacing it. Both are rarer than assumed.

What if there is no documentation?

Normal. Characterisation tests document behaviour as you go, which is more reliable than documentation anyway.

Can we add a framework to existing code?

Incrementally, yes — routing new functionality through it while old code continues to work. That is the usual path.

Keep reading

Application on an unsupported PHP version?

That is the urgent part and usually the smallest. Happy to assess what upgrading would involve.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

Web DevelopmentCustom Software Development