Legacy PHP Modernisation

Trade Supplier Order Desk: CodeIgniter Upgrade & Laravel Migration

A ten-year-old CodeIgniter order desk brought onto PHP 8, made fast again, and moved to Laravel one module at a time without a day of downtime.

View live demo Opens a working demo with sample content in a new tab.
Fenwick Trade Supplies demo on desktop and phone

On location

  • Construction Tools — Fenwick Trade Supplies
    Construction ToolsPhoto: The World is a Stage (CC0)
  • Construction Tools — Fenwick Trade Supplies
    Construction ToolsPhoto: The World is a Stage (CC0)
  • Construction Tools — Fenwick Trade Supplies
    Construction ToolsPhoto: The World is a Stage (CC0)
  • Measuringtape Measurement — Fenwick Trade Supplies
    Measuringtape MeasurementPhoto: Peter Belch (CC0)
  • Tools Hammer — Fenwick Trade Supplies
    Tools HammerPhoto: La Compagnie Robinson (CC0)

About the Project

This legacy PHP modernisation project rescued the order desk of a building trade supplies distributor. Its whole trade counter ran on a CodeIgniter 2 application written in 2016 by a contractor who had long since moved on. It handled around 600 orders a day, but the hosting provider was retiring PHP 5.6, several screens took more than eight seconds to load and nobody dared change the code.

A full rewrite had been quoted at nine months, which the business could not wait for. Instead we modernised in place: first a CodeIgniter upgrade to PHP 8 so the application stayed supported, then performance fixes, then a gradual move to Laravel, one module at a time, behind the same URLs and without a day of downtime.

About the Client

The client is a building trade supplies distributor serving builders, plumbers and electricians on trade accounts with negotiated prices. Counter staff and phone sales use the order desk all day to raise orders, check stock, apply pricing and produce invoices.

The application had no tests and no documentation, and its pricing rules, including trade discounts and customer-specific prices, existed only in the code. Any change risked charging customers the wrong amount, which is why the system had been left untouched for years.

Project Goals

  • Move the application onto a supported PHP version before the host’s deadline.
  • Protect the pricing engine with tests before changing anything that could affect prices.
  • Bring every slow screen under one second.
  • Start replacing old modules with Laravel without changing how staff work.
  • Put every change under version control with automated checks.

Project Overview

The Challenge and Our Solution

The Challenge

The distributor’s entire trade counter ran on a CodeIgniter 2 application written in 2016 by a contractor who had long since moved on. It processed 600 orders a day, but the host was retiring PHP 5.6, several screens took over eight seconds to load, and nobody dared touch the code. A full rewrite had been quoted at nine months, which the business could not afford to wait for.

Our Solution

We mapped the application first — 214 controllers, 96 database tables, no tests — and then worked in stages. Stage one made it run on PHP 8.3 with CodeIgniter 3, fixing 340 incompatibilities on a copy and testing every screen against a snapshot of live data. Stage two fixed the slow pages: missing indexes, N+1 queries in the pricing engine and a report that loaded the whole order history to display one week. Stage three began the move to Laravel, module by module behind the same URLs, starting with the areas the business wanted to change most.

Mapping an Application Nobody Understood

We started by mapping the system: 214 controllers, 96 database tables and no tests. Each screen was traced from route to query so we knew what it read, what it wrote and which business rules it applied. The result was a map of risk that told us where to tread carefully and where change was safe.

That map also shaped the order of work. Pricing was the most sensitive area, so it was protected first; reports and stock screens were the slowest, so they were tuned early; and the modules the business wanted to change most were first in line for Laravel.

  • Every route, controller and table catalogued
  • Business rules extracted from the code
  • A risk map guiding the order of work

A Safe CodeIgniter Upgrade to PHP 8

Stage one moved the application to CodeIgniter 3 on PHP 8.3. Working on a copy, we fixed 340 incompatibilities: deprecated functions, removed extensions and changes in error handling. Every screen was tested against a snapshot of live data so behaviour could be compared before and after.

The upgraded application went live on a supported PHP version three weeks before the host’s deadline, with staff noticing nothing except that some screens were already faster.

PHPUnit Tests Around the Pricing Engine

Before touching pricing logic we wrapped it in PHPUnit tests for legacy code: trade bands, quantity breaks, contract prices, VAT rounding and delivery thresholds, all checked against results from the old system. Those tests run automatically in GitHub Actions on every change, so an upgrade or refactor cannot silently alter what a customer pays.

With the safety net in place, performance work could begin. Missing indexes were added, N+1 queries in the pricing engine were rewritten, Redis caching was introduced for repeated lookups, and a report that loaded the entire order history to show one week now queries only what it needs. The slowest screens fell from eight seconds to under half a second.

A Strangler Pattern Laravel Migration

Stage three began replacing the old code with Laravel 11 using the strangler pattern. New modules run in Laravel behind the same URLs and share the database and session with the CodeIgniter application, so staff move between old and new screens without noticing a seam.

Four modules have been rebuilt so far, chosen because they were the areas the business wanted to improve, with no change to how the team works. Each further module can be migrated when there is value in doing so, rather than in one risky big-bang rewrite.

Our Process

How We Delivered It

  1. Mapping and Risk Assessment

    We catalogued routes, controllers, tables and business rules to understand exactly what the application did and where the risk lay.

  2. Tests Before Changes

    The pricing engine was covered by tests built from the old system’s own results before any code was altered.

  3. PHP 8.3 Compatibility Pass

    CodeIgniter was upgraded and 340 incompatibilities fixed on a copy, with every screen checked against live data snapshots.

  4. Performance Tuning

    Indexes, query rewrites and Redis caching brought every screen under one second, measured before and after.

  5. Module-by-Module Laravel Migration

    New Laravel modules were introduced behind the same URLs, sharing data and sessions with the existing application.

Key Features

What We Delivered

  • PHP 8 compatibility pass

    Deprecated functions, removed extensions and error-handling changes fixed and tested screen by screen.

  • Pricing engine tests

    The trade-discount logic covered by tests before anything was touched, so upgrades could not silently change prices.

  • Strangler migration to Laravel

    New modules in Laravel share the database and session with the old application, so users see one system.

  • Performance fixes

    Indexes, query rewrites and caching brought every screen under one second.

Outcome

Results and Impact

  • Running on a supported PHP version three weeks before the host’s deadline.
  • Slowest screens down from 8s to under half a second.
  • Four modules rebuilt in Laravel so far, with no change to how staff work.
  • Every change in version control with automated tests around the pricing engine.

Services

Services Behind This Project

The PHP & Laravel, CodeIgniter, Custom Web expertise we used to build this legacy php modernisation — and can bring to yours.

  • PHP & Laravel Development

    Laravel web applications, custom PHP development, admin panels, APIs and legacy PHP upgrades — secure, well-structured and easy to maintain.

  • CodeIgniter Development

    New features, bug fixes and PHP 8 upgrades for CodeIgniter 3 and 4 applications — and a planned move to Laravel when the time is right.

  • Custom Web Development

    Bespoke websites and web applications engineered around your workflows — fast, secure, and built to scale with your business.

FAQ

Frequently Asked Questions

Should we rewrite our legacy PHP application or modernise it in place?

A full rewrite stops progress for months and carries the risk of losing business rules that only exist in the old code. Modernising in place keeps the system running while you upgrade the platform, add tests, fix performance and replace parts gradually. For most working business applications it is the lower-risk path.

How do you upgrade CodeIgniter to PHP 8 safely?

Work on a copy, upgrade the framework version, fix incompatibilities such as deprecated functions and removed extensions, and test every screen against a snapshot of real data. Comparing before and after behaviour screen by screen is what makes the switch safe, and it is how this application moved to PHP 8.3 without disruption.

What is the strangler pattern?

The strangler pattern replaces an old system piece by piece. New modules are built in the new framework and placed behind the same URLs, sharing the database and session, so users see one application. Over time more of the old code is retired until little or nothing remains, without a single high-risk switchover.

Why write tests for code you are about to replace?

Tests capture what the system does today, including rules nobody wrote down. Around pricing, that matters enormously: a small mistake could charge customers the wrong amount. Tests built from the old system’s results let you upgrade and refactor with confidence, and they keep protecting the logic after it moves to the new framework.

How much faster can a legacy PHP application become?

It depends on the causes. Missing indexes, N+1 queries and reports that load far more data than they show are common and very fixable. In this project the slowest screens went from around eight seconds to under half a second, mostly through database and query work plus caching.

Will staff need retraining during the migration?

Not if the work is planned around them. Upgrades and performance fixes change nothing visible, and Laravel modules can keep the same workflows and URLs. Here, four modules have been rebuilt with no change to how staff work, so the business improved its system without pausing to retrain the counter team.

Similar Work

Related Projects

Case studies built with the same technologies or for similar needs.

  • Gears Chains — Hartwell Industrial
    • Magento 2
    • PHP 8
    • MySQL

    Magento eCommerce

    Industrial Parts B2B Store

    An 84,000-SKU Magento 2 store with contract pricing, quick order and ERP-synced stock for trade accounts.

  • Free big open, multiple level — Faculty of Science
    • Drupal 10
    • PHP 8
    • Twig

    Drupal Website

    University Faculty & Research Portal

    A multilingual Drupal portal for 6,800 pages, 140 editors and three languages, built to WCAG 2.2 AA.

  • Student School — Learnwell
    • Docker
    • GitHub Actions
    • Nginx

    Cloud & DevOps

    Learning Platform Cloud Migration

    A containerised rebuild of a fragile single-server deployment: 4-minute releases and 58% lower hosting cost.

  • Restaurant Dining — Laurel Group
    • WordPress Multisite
    • PHP 8
    • Custom theme

    WordPress CMS Website

    Restaurant Group Multisite

    A WordPress multisite giving seven restaurants their own identity, with shared menus, bookings and gift cards.

  • Business Team — Northgate Training
    • WordPress
    • LMS & membership plugins
    • PHP 8

    WordPress CMS Website

    Accredited Training & Membership Portal

    A WordPress learning portal with courses, assessments, certificates and employer team accounts.

  • Factory machinery manufacturing — Ardley Valves
    • WordPress
    • ACF Pro
    • PHP 8

    WordPress CMS Website

    Manufacturer Technical Product Catalogue

    A 4,200-product technical catalogue with specification filtering and CAD downloads, fed from the PIM.

Let’s Connect

Want Results Like These?

Share your project details and our experts will get back to you within one business day with the best solution — free consultation, no obligation.