The Challenge: “It Works, But We’re Scared to Touch It”
Your legacy PHP application (likely built on CodeIgniter, CakePHP, Symfony 1.x, or a Custom MVC) is the backbone of your business. But it’s brittle. Developers are afraid to deploy. Security patches for PHP 5.6 or 7.x are long gone.
Migrating to Laravel is the industry standard for modernizing PHP. It offers a robust ecosystem, strict security defaults, and a developer experience that helps you hire top talent. But getting there without breaking the business is the hard part.
Technical Deep Dive
1. The “Strangler Fig” Pattern
The only safe way to migrate a live application is incrementally. We use the Strangler Fig Pattern:
- Install Laravel alongside your legacy app.
- Configure Nginx/Apache to route specific URLs to Laravel, while defaulting everything else to the legacy app.
- Migrate one module (e.g., User Profile) to Laravel.
- Switch the route to point to Laravel.
- Repeat until the legacy app is gone.
2. The Session Problem
The biggest technical hurdle is sharing state. When a user logs into the Legacy app, they must be logged into Laravel, and vice versa.
- Solution: Use a shared session store (Redis or Database).
- Implementation: Write a custom Laravel Session Driver (implementing
Illuminate\Contracts\Session\Session) that reads the legacy session format, or update the legacy app to write Laravel-compatible sessions.
3. Database Coexistence
You cannot simply “change the database” overnight.
- Strategy: Both applications connect to the same database.
- Eloquent Models: Create Laravel Eloquent models that map to your existing legacy tables. You do not need to rename tables immediately.
class User extends Model { protected $table = 'tbl_usr_01'; // Map to legacy table protected $primaryKey = 'id_usr'; } - Refactoring: Rename columns and restructure tables after the code migration is complete, using Laravel Migrations.
Architecture Transformation
graph TD
subgraph "Server"
A[Web Server / Load Balancer] -->|Route: /new-feature| B[Laravel App]
A -->|Route: /legacy-path| C[Legacy PHP App]
B --> D[(Shared Database)]
C --> D
B --> E[(Redis Session Store)]
C --> E
end
style B fill:#ff2d20,stroke:#333,stroke-width:2px,color:white
style C fill:#8892bf,stroke:#333,stroke-width:2px,color:white
How to Choose a PHP to Laravel Migration Partner
If you need to reskill your team: Vehikl. Their “Mob Programming” approach means they code with your team, teaching them TDD and Laravel best practices as they migrate. You end up with a modernized app AND a modernized team.
If you have a complex, high-traffic domain: Spatie. They are the architects of the modern Laravel ecosystem. If your domain logic is knotty and performance is critical, they are the best in the world.
If you need enterprise-grade consulting: Tighten. They specialize in working with large organizations and navigating the organizational challenges of migration, not just the code.
If you are budget-conscious: Belitsoft or 10Clouds. They offer high-quality engineering talent at competitive rates, ideal for labor-intensive refactoring work.
Red flags:
- “We’ll rewrite it in 3 months.” (They won’t. It will take 12, and it will be buggy.)
- “We don’t write tests.” (Migration is refactoring. Refactoring without tests is suicide.)
- “We’ll use an automated converter tool for everything.” (Tools like Laravel Shift are great helpers, but they don’t fix architectural rot. Human insight is required.)
When to Hire PHP Migration Services
1. Security Compliance Failure (SOC2 / ISO 27001)
Your penetration test failed because you’re running PHP 5.6 or 7.0. You cannot upgrade PHP because the legacy framework doesn’t support PHP 8.x. Trigger: “We failed our SOC2 audit due to EOL software.”
2. Feature Paralysis (Velocity Collapse)
Adding a simple feature takes weeks because the code is “spaghetti.” New developers take months to onboard because there is no documentation and “magic” global variables everywhere. Trigger: “It took 3 weeks to change a button color.”
3. Talent Drain
Good developers don’t want to work on CodeIgniter 2 in 2025. They want to work with Laravel, Vue, and React. You are losing your best people to companies with modern stacks. Trigger: “Our lead dev just quit.”
Total Cost of Ownership: Legacy vs. Laravel
| Line Item | Legacy PHP (Annual) | Modern Laravel (Annual) |
|---|---|---|
| Hosting | High (Inefficient code, vertical scaling) | Low (Horizontal scaling, Serverless) |
| Maintenance | $150k (Bug fixes take forever) | $50k (Clean code, automated tests) |
| New Features | Slow (High risk of breaking things) | Fast (CI/CD, confident deployment) |
| Security Risk | Critical (Unpatched vulnerabilities) | Low (Auto-updates, secure defaults) |
Break-Even Analysis:
- Migration Cost: $150k (One-time)
- Annual Savings: $100k
- Break-Even: 1.5 Years
Typical Migration Roadmap
Phase 1: Preparation (Weeks 1-4)
- Dockerize the legacy application (ensure consistent environment).
- Add Tests to the most critical paths (Login, Checkout) using Cypress or Playwright.
- Install Laravel and configure the web server (Strangler Fig setup).
Phase 2: The “Walking Skeleton” (Weeks 5-8)
- Implement Shared Authentication (Users can log in to both apps).
- Migrate the Layout/Shell (Header, Footer, Navigation) so users don’t see a visual jar between apps.
Phase 3: Incremental Migration (Months 3-12)
- Pick a module (e.g., “Invoices”).
- Write Feature Tests in Laravel.
- Implement the logic in Laravel (refactoring as you go).
- Switch the route.
- Delete the legacy code for that module.
Phase 4: Cleanup (Month 13)
- Remove the legacy app files.
- Refactor the database schema (rename tables/columns).
- Celebrate!
FAQ
Why not just rewrite in Node.js or Go?
PHP is alive and well. Laravel is faster to develop in than almost anything else. If your team knows PHP, moving to Laravel leverages their existing skills while giving you modern power. Rewriting in a new language throws away all your domain knowledge and requires a completely new hiring strategy.
Can we use automated tools like Laravel Shift?
Yes! We love Laravel Shift for upgrading existing Laravel apps. For legacy PHP code, we use Rector. Rector is an automated refactoring tool that can instantly upgrade old PHP syntax (e.g., array() to [], adding type hints) to modern standards. However, moving from a custom legacy framework to Laravel requires human architectural decisions that tools can’t make.
What happens to our data?
Your data stays right where it is. We connect Laravel to your existing database. We might add some new tables for Laravel features (like migrations, jobs, sessions), but your core business data remains untouched until we explicitly decide to refactor the schema.