Insight
PHP legacy systems: stabilise, refactor, or rewrite?
The rewrite seduction is strong and often wrong. How to decide what inherited Laravel and PHP code actually needs before anyone quotes six months of greenfield work.
Inherited PHP codebases generate strong opinions and weak estimates. Vendors promise rewrites. Internal teams fear touching production. Leadership waits while delivery slows. The way out is assessment first, not a default rewrite.
Why do big-bang rewrites fail?
Short answer: Undocumented behaviour, parallel systems that diverge, and business that cannot pause while v2 slips.
Big-bang rewrites fail because:
- Behaviour is undocumented. Edge cases live in code nobody read.
- Parallel systems diverge. The rewrite never catches up with production changes.
- Business cannot pause. Revenue workflows still run on the old system while v2 slips.
- Integration debt migrates. Brittle CSV jobs get reimplemented badly instead of redesigned.
Rewrite is sometimes correct for a bounded module, not an entire company platform. It only fits after assessment shows refactor cost exceeds rebuild cost for that module.
What are the three paths?
Short answer: Stabilise to make change safe again. Refactor to improve structure without changing outward behaviour. Rewrite one module when maintenance cost clearly exceeds rebuild cost.
1. Stabilise
Goal: Make the system safe to change again.
Typical work:
- Fix critical production bugs and deployment path
- Add automated tests on the most dangerous code paths
- Document architecture, integrations, and runbooks
- Stop direct production hotfixes without staging
When it fits: The system works but every change is terrifying. Business cannot absorb a long rewrite. Technical debt is broad but not uniformly rotten.
Cost: A focused rescue pass after assessment. Current bands on Pricing and Legacy modernisation.
2. Refactor
Goal: Improve structure without changing outward behaviour users depend on.
Typical work:
- Extract services from god classes
- Modernise Laravel patterns incrementally
- Reduce coupling between modules
- Clarify data models and migrations
When it fits: Specific areas are unmaintainable but the overall architecture is salvageable. Tests (added during stabilisation) protect behaviour during change.
3. Selective rewrite
Goal: Replace one module where maintenance cost clearly exceeds rebuild cost.
Typical work:
- Strangle one vertical slice: new module, old module retired when proven
- Migrate data with validation and rollback plans
- Integrate via documented APIs rather than copy-pasting old SQL
When it fits: A bounded subdomain (billing export, admin permissions, one integration hub) is clearly beyond refactor economics.
Why assess before quoting?
Short answer: Quotes without repository access are fiction.
A Discovery Sprint or focused assessment produces:
- Integration inventory (APIs, cron jobs, email parsers, manual exports)
- Risk register ranked by business impact
- Phased roadmap: stabilise first, then improve
- Fixed estimate for phase one only
Paid upfront. Deliverables yours. Fee credits to build if you continue with GalTech.
What about Laravel specifically?
Short answer: Many "legacy" systems are Laravel versions behind with patchwork packages. That is often upgrade + stabilise + refactor, not rewrite.
- Laravel upgrade path planned with test coverage on critical paths
- Package replacements scoped one at a time
- PostgreSQL or MySQL schema cleaned incrementally
New and migrated components follow what we can maintain long-term. Specific choices are confirmed in discovery. See Proof for how we document delivery decisions.
Where does legacy pain usually live?
Short answer: Integrations: undocumented scripts, duplicate data stores, manual CSV rituals.
Integration design is covered on Backend systems.
Replacing a brittle script with a documented sync job is often higher return than rewriting the entire admin UI.
When do you need help now?
If estimates always include "unknown side effects," only one person can deploy, or production fixes skip staging, the system already needs the kind of assessment described above. See Legacy modernisation for warning signs and how a rescue is scoped.
How do you spot an oversold rewrite?
- Quote arrives without code access
- No phased plan, only a twelve-month greenfield timeline
- No mention of data migration validation
- Promise to "modernise everything" without prioritisation workshop
What will GalTech not do?
We hold the same engineering boundaries here that we do on every legacy engagement: no default rewrite recommendation, no undisclosed data migration risk. See Legacy modernisation for the full list and service detail.
Practical next step
If delivery is slowing and nobody wants to touch the codebase, start with assessment, not a rewrite RFP.
Book a fit call or request a Discovery Sprint with repository access ready.