Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
  1. Home
  2. Blog
  3. Improving Old Code Without a Rewrite
PHP Development

Improving Old Code Without a Rewrite

Modernising a legacy PHP application without a rewrite: move to a supported PHP version, add tests around what matters, then strangle rather than replace.

Updated 2 min readBy SpiderHunts Technologies

Free estimateNo obligation

Get a free estimate

Tell us what you need. A senior engineer reads every enquiry.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →

Quick answer — TL;DR

Get onto a supported PHP version first, add tests around what matters, then improve incrementally. Full rewrites of working business applications fail more often than they succeed.

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.

FAQ

Frequently asked questions

The questions readers ask us after this guide.

Still have a question?

Ask us directly — a senior engineer will get back to you.

Ask about your project

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

More on PHP Development

PHP Development

Why PHP Is Still a Sensible Choice

Is PHP still a good choice for business applications? Where modern, typed PHP fits, where another language is better, and the hosting and hiring arguments.

PHP Development

Framework, Micro-Framework or Neither

Choosing a PHP framework for a business application: when a full framework, a micro-framework or no framework fits, and why business logic stays separate.

Start here

Application on an unsupported PHP version?

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

  1. You tell us what you needTwo minutes on the form, or a message on WhatsApp.
  2. A senior engineer reviews itAnd comes back with questions, a realistic range and an honest view on fit.
  3. Free 30-minute scoping callWe talk through scope, options and a realistic estimate — with no obligation.
Free estimateNo obligation

Talk to someone who builds this

Send a short brief and we will come back with an honest view and a realistic range.

Takes under a minute. We never share your details.

  • Free consultation
  • No commitment
  • NDA on request

Prefer to talk? Book a free 30-minute call →