Legacy PHP

Legacy PHP modernization without stopping the business

Old PHP that still runs your company can be made safe to change again. We wrap it in tests, replace it one piece at a time and keep it in production while the work goes on.

  • No big-bang rewrite
  • Tests before changes
  • Live system keeps running
What is included
  • Characterization tests
  • Strangler pattern
  • Composer and namespaces
  • PDO in place of mysql functions
  • Service layer extraction
  • Move to CodeIgniter 4 or Laravel
Get a free quote Reply within one business day. NDA on request.
The problem

Living with a legacy PHP system

Somewhere in your company there is a PHP system older than most of the staff who use it. It might be hundreds of procedural scripts that include each other, a home-made framework, an early CodeIgniter or another framework its authors walked away from. SQL is written inline, HTML and logic share the same files, and the server it runs on cannot be updated because the code would stop working.

It also holds years of business rules that exist nowhere else. That is why throwing it away and starting over fails so often: the rewrite takes far longer than promised, and the old system has to be kept alive anyway. Modernization is the alternative. We change the architecture of the code gradually, with the system in daily use throughout. This page is about the code and its structure. If your main concern is the PHP version itself, see PHP migration and upgrade.

  • Nobody dares change it

    Every edit risks a side effect three files away. Developers refuse the work or pad estimates heavily, and the business has stopped asking for improvements.

  • Stuck on an old server

    The code depends on functions and settings that newer PHP removed. So the server stays frozen, unpatched, and your hosting provider or security team is losing patience.

  • A failed rewrite behind you

    You already tried to rebuild from scratch. After a year the new system covered half the features, the old one was still in use and the budget was gone.

  • Hiring is impossible

    Good developers do not want to work in a codebase with no framework, no tests and no tooling. The one person who understands it is close to retiring or leaving.

What we do

Techniques we use to modernize old PHP

Modernization is a set of small, reversible moves applied in a sensible order. These are the ones we rely on.

Characterization tests

Tests that record what the system does today, right or wrong, by capturing real inputs and outputs. They become the alarm that sounds when a change alters behavior.

Strangler pattern

A new application placed in front of the old one. Requests are routed to new code feature by feature, and the legacy part shrinks until it can be removed.

Composer and namespaces

Autoloading in place of chains of include and require, classes organized under namespaces, and maintained packages replacing home-made mailers, PDF writers and utilities.

PDO in place of mysql functions

Database access moved to PDO with prepared statements, closing SQL injection holes and removing the dependency on extensions that newer PHP no longer ships.

Service layer extraction

Business rules pulled out of page scripts into plain classes that can be tested alone and called from old pages and new framework controllers alike.

Move to CodeIgniter 4 or Laravel

Screens rebuilt on a current framework one area at a time, sharing the database and login with the legacy code until the last old page is retired.

Typical projects

Legacy systems we modernize

01

Procedural PHP application

Hundreds of standalone scripts with inline SQL and mixed HTML, brought under a front controller, given a service layer and moved gradually onto a framework.

02

Abandoned or home-made framework

A system built on a framework that is no longer maintained, or one a former developer invented, replaced from the edges inward while it keeps working.

03

PHP 5-era CodeIgniter system

A very old CodeIgniter application with edited core files and outdated libraries, stabilized first, then moved in sections to CodeIgniter 4 or Laravel.

04

Critical module first

Only the riskiest part, such as billing or payroll calculations, covered with tests and rebuilt cleanly, leaving the rest of the system for a later phase.

In depth

Replacing old PHP one piece at a time

Why rewrites fail and increments work

A full rewrite asks the business to wait a long time for a system that does what the old one already does, while paying to keep the old one alive. Requirements keep changing in the meantime, and hidden rules surface late. Incremental modernization delivers working software continuously. At every point there is one production system, part old and part new, and the project can be paused after any stage with the gains already banked.

Capture behavior before touching it

Legacy code has no specification except itself. So the first job is characterization testing: we record real requests and the responses, database changes and files they produce, then replay them automatically. For calculation-heavy code we feed in a large sample of historical records and store the results. These tests do not judge whether the behavior is correct. They only tell us when it changes, which is exactly the safety net refactoring needs. Bugs we discover are listed for you to decide on, and not silently fixed.

Lay the foundations inside the old code

Next come changes that make the old code easier to work with and alter no behavior. Composer is introduced and an autoloader takes over from include chains. All requests are funneled through a single front controller. Configuration and credentials move out of scattered files. Calls to the removed mysql extension are replaced with PDO and prepared statements behind a small database class. Global variables and superglobals are pushed to the edges. Static analysis and automated refactoring tools do much of the repetitive work, with the characterization tests confirming nothing shifted.

Extract the rules, then strangle the rest

With the ground stable, we pull business logic out of page scripts into service classes: pricing, eligibility, stock allocation, whatever makes your system yours. Those classes are plain PHP and work under any framework. Then a CodeIgniter 4 or Laravel application is placed in front. The web server or the new router sends each URL either to new controllers or to the legacy front controller. Both share the session and the database. Feature by feature, routes move across. CodeIgniter 4 suits teams that want to stay light. Laravel suits products heading toward queues, billing and larger teams.

Keeping the business running meanwhile

Releases are small and frequent, each one reversible. Urgent fixes to the old code continue throughout and are covered by the same tests. We agree the order of work with you by business risk and pain, not by technical neatness. If the legacy system happens to be a CodeIgniter 3 application in reasonable shape, a direct CodeIgniter 3 to 4 upgrade may be shorter than this route, and we will tell you so. For the wider picture across platforms, see migration and modernization.

Process

A modernization program in stages

  1. 1

    Codebase assessment

    We read the codebase, measure its size and dependencies, interview the people who use and maintain it, and report on condition and options.

  2. 2

    Tests around the core paths

    Version control, a reproducible staging environment and characterization tests around the paths the business depends on most, before any refactoring begins.

  3. 3

    Groundwork in the old code

    Composer, autoloading, a front controller, PDO and centralized configuration introduced inside the existing code without changing behavior.

  4. 4

    Extract and replace

    Business rules move into services and screens move to the new framework in agreed slices, each released to production when ready.

  5. 5

    Retire the legacy

    When the last route has moved, old code and unused tables are archived and the server is updated to a current PHP release.

Deliverables

Where modernization leaves you

  • A written assessment with options and trade-offs
  • Characterization tests around business-critical paths
  • Business rules in framework-independent service classes
  • Every query running through PDO with bound parameters
  • A current framework and PHP release under the system
FAQ

Modernization questions owners raise

Why not simply rewrite the whole system from scratch?
Because full rewrites of working business systems frequently overrun and leave you paying for two systems. Incremental modernization keeps one system in production, delivers improvements continuously and lets you stop or change direction at any stage without losing what has been done.
Our code has no tests at all. Where do you begin?
With characterization tests. We record what the system currently does for real inputs and replay those recordings automatically. They need no prior documentation and give us a way to detect unintended changes before any restructuring starts.
Will staff have to stop using the system during modernization?
No. The system stays in production the whole time. Changes are released in small steps, each tested and reversible. Most users notice only that pages gradually look or respond better as sections move to the new framework.
Should the new parts be built on CodeIgniter 4 or Laravel?
It depends on where the product is going. CodeIgniter 4 is light and close to plain PHP, which suits internal systems and small teams. Laravel brings more built-in features for growing products. Because we extract rules into plain classes first, the choice can be made with evidence.
How is this different from a PHP version upgrade?
A version upgrade makes existing code run on newer PHP. Modernization changes how the code is organized: tests, autoloading, separated business logic and a real framework. The two overlap, and modernization usually includes the version upgrade along the way.
How do you price work on a codebase this old?
By stage, after an assessment. The main cost factors are the size of the codebase, how tangled data access and presentation are, how many external systems it talks to and how much of it you want moved. The assessment gives you these figures, and work is quoted in stages so you commit one step at a time.
Can our own developers take part?
Yes, and it helps. People who know the system explain the hidden rules, review changes and learn the new structure as it appears. We can also add capacity through a dedicated development team working alongside them.
Start a project

Have an old PHP system that needs a future?

Describe the system: roughly how old, how big, what it runs on and what scares you about it. We will reply within one business day and arrange a free consultation with one of our PHP developers.

  • Free consultation and quote
  • NDA on request
  • You own the source code
  • Reply within one business day
Add budget and timeline optional, helps us quote faster

This form is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.