Migrating a legacy PHP app without a big-bang rewrite

Migrating a legacy PHP app without a big-bang rewrite

Full rewrites are where roadmaps go to die: months with nothing to show, a moving target, and a cutover nobody trusts. Migrate incrementally instead.

Stabilise first

Get the legacy app into version control, running locally, and behind a few end-to-end tests on the money paths. You cannot safely change what you cannot run and check.

Put a seam in front

Route all traffic through a thin proxy or front controller. Now you can send specific URLs to a new service while everything else still hits the old code.

Move one capability at a time

  • Pick a bounded area — reporting, auth, a single module.
  • Rebuild it in the new stack against the same database.
  • Flip that route. Watch errors and latency. Keep the old path warm for a quick rollback.

Share the database, briefly

Both systems read and write the same tables during the transition. It is not elegant, but it means every step is small and reversible. Split the data last, once the new system owns a capability outright.

Users get a steadily improving app; the team never disappears for a quarter.

Upgrading PHP itself

Many legacy applications are stuck on unsupported PHP versions that no longer receive security fixes. Upgrade in steps: run static analysis to find incompatibilities, fix deprecations, run your tests, then move one version at a time. Each step is small and can be deployed on its own.

Adding tests to code that has none

Start with characterisation tests: tests that record what the code currently does, right or wrong, for the most important flows. They let you refactor without changing behaviour unknowingly. Add unit tests as you extract logic into cleaner classes.

Choosing the target

For most PHP teams, the natural destination is a modern framework such as Laravel or Symfony: the language stays the same, the team's skills carry over, and the old and new code can run side by side. Switching language entirely multiplies the risk and should be justified by a clear need.

Communicating progress

Incremental migrations succeed when the business can see progress. Publish a simple map of which areas are migrated, in progress and remaining, and ship user-visible improvements — faster pages, fixed long-standing bugs — along the way, so the project never looks like a cost with no return.

When a rewrite is justified

If the application is small, the business process has fundamentally changed, or the existing code is genuinely unrecoverable, a rewrite can be right. Even then, release it in stages rather than in one switch-over.

Talk to us

Stuck with an old PHP system? See our PHP & Laravel development, or get a free quote — we reply within one business day.

Need a team to build it?