The problem
A revenue-generating platform ran on an unsupported framework and shared cPanel hosting, with no test suite, no version history, no automated deploy and a local setup almost nobody could reproduce — so every change was a production gamble.
The approach
- 01Brought the codebase under version control and reconstructed how it actually worked
- 02Migrated production off shared cPanel hosting onto managed cloud infrastructure
- 03Replaced manual file-copy releases with an automated deploy pipeline
- 04Containerised local development and collapsed the setup process to a handful of steps
- 05Pulled business logic out of controllers into an injectable service layer, module by module
- 06Backported the framework facilities the code needed rather than attempting a risky wholesale upgrade
- 07Kept the accounting integrations and the nightly batch pipeline running throughout
How it works
The domain
The centre of the product is the "cube" — a financial year model per customer that holds income, direct costs, overheads and wages, each broken down by work type and by month. Around it sit forecasting versions, budgets, profit-and-loss actuals, balance sheet data and a weekly cash-flow projection. That single concept accounts for a large share of the 213 models: the expense side alone fans out into equipment, vehicle, marketing, office, professional and employee tables, each with a monthly counterpart.
Tenancy and permissions
Access runs through a four-level hierarchy — white-label partner, organisation, coach or team member, and end business — with a per-module permission matrix layered on top and audit logs recording every change to it. Menu construction, dashboard widgets and route access all resolve against that matrix, which is why the sidebar and dashboard ended up as dedicated facade-backed builders rather than view logic.
Accounting integrations
Xero and MYOB connections sync chart-of-accounts, profit-and-loss, balance sheet and payroll data into the platform, mapped onto the customer's own account structure through a configurable mapping layer. Sync runs unattended: scheduler logs, error logs and notification emails exist because a silent failure here means a customer opens a forecast built on stale numbers. A separate token-authenticated API syncs jobs, quotes, invoices and projects two ways with a sister field-service product.
The batch layer
Thirteen scheduled commands carry the work that cannot happen in a request: nightly accounting imports, connection health checks, subscription renewals and invoicing, event and action reminders, performance and sales-pipeline notifications, and the outbound email queue. Each is a thin console command delegating to the same service classes the HTTP layer uses, so the scheduled path and the interactive path cannot drift apart.
Where it runs
Production is a provisioned cloud server on DigitalOcean running nginx and PHP-FPM, managed through Laravel Forge, with deploys triggered automatically from the default branch. That replaced the shared cPanel account the platform had been living on, where releases were a manual file copy, the cron table was edited by hand through a control panel, and the PHP version was whatever the host had decided to offer that quarter.
Decisions
Decision 01
Modernise inside the framework rather than upgrade it
The application targets Laravel 5.2 on PHP 7.1. A jump to a supported release would have meant rewriting 591 routes, 512 templates and every integration at once, with no test suite to catch what broke. Instead I backported what the code actually needed: a Mix manifest helper for asset versioning, view composers to drain logic out of templates, service providers and facades for the cross-cutting helpers, and a reflection-based Blade directive layer with its own generators, so custom directives and composers could be scaffolded the way later framework versions scaffold them. Slower than an upgrade, but every step was independently shippable.
Decision 02
A service layer as the refactoring seam
Controllers had grown to thousands of lines each — the user controller alone is over 6,000. Rather than rewrite them, I introduced 65 constructor-injected services and moved logic across one module at a time, letting controller and service coexist during the move. The services became the shared surface that console commands, the API and the web layer all call, which is what made the batch layer trustworthy.
Decision 03
Fix the environment before touching the code
Standing the project up locally was the single worst part of inheriting it: scattered configuration, hardcoded paths, and a long tail of setup keys and credentials that existed only in somebody's memory or on the live server. I containerised it — nginx and PHP 7.1 with local TLS — and refactored configuration until a working environment was a short, written-down sequence rather than a week of archaeology. Reproducing an eight-year-old runtime is the precondition for changing it safely; until that existed, the only test bed was production, and that was the real risk, not the code quality.
Decision 04
Move production off shared hosting, then automate the release
The platform ran on a basic cPanel account — no deploy pipeline, no environment parity, no control over the PHP runtime, and releases performed by copying files onto a live server. I migrated it to a DigitalOcean server provisioned and managed through Laravel Forge, then wired up automatic deployment from the default branch. The trade-off is real: a managed server costs more than shared hosting and someone now owns patching it. In exchange, releases became repeatable and reversible instead of an act of nerve.
What it doesn't do
- No automated test suite, and I chose not to retrofit one. Across ~99k lines of controller-heavy legacy code with no seams, meaningful coverage would have cost more than the remaining lifespan of the codebase justified. Safety came from containerised verification, small reversible commits and an automated deploy instead — a deliberate trade, and the thing I would change first if the platform had a longer runway.
- The framework stays at end-of-life. The service layer is groundwork for a successor, not a migration in itself.
- Reporting depends on a Power BI Embedded workspace API that Microsoft has since retired, so that surface is frozen rather than maintained.
Where it stands
The platform has reached end of life and a successor is in active development — but v1 is still in production and customers are still working in it every day. The job now is keeping it steady and predictable while its replacement is built, not extending it.