Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

n2fole00's avatar

Converting a Legacy PHP/MySQL App into a Laravel-Powered RESTful API

Hi, My workplace product is an old legacy PHP/MySQL application (with its own home-grown framework), and we're planning to convert it into part of a micro-services architecture with our product powered by Laravel. I've been asked for input about this and have no idea how to go about it. I've played around with Laravel over the years, but never made anything I'm using to this day.

I’d love to hear from anyone who has done a similar migration. Perhaps there is some video or reading source that you would recommend that addresses this very topic. Even some keywords I could google might be helpful.

Thanks in advance for your insights!

0 likes
6 replies
martinbean's avatar

@n2fole00 You‘re not going to find any nice videos or reading sources because migrating a project is very project-specific.

When I’ve worked on projects like this where you’re converting a vanilla PHP application to a framework like Laravel, I usually:

  1. Create a new Laravel project
  2. Rename Laravel’s public/index.php file to public/laravel-index.php
  3. Dump the old application’s files in the public directory
  4. Configure the web server to either try and pass the request through Laravel’s front controller first, or fall back to passing the request to a script with the requested filename/URI

This then gives you an integration point, and you can start slowly re-factoring scripts into Laravel controllers and whatnot.

So, initially, all requests should just be getting handled by the legacy application. Find a single script/endpoint, convert it to a Laravel route and delete the old script, and you now have a single route being handled by Laravel, with the rest falling back to the legacy application. If you repeat this process, you should find the number of Laravel classes grow, and the number of legacy files shrink, until you have none of the legacy application’s files left.

3 likes
jlrdw's avatar

+1 to @martinbean answer.

There are some past post on it as well, one Like @martinbean answer, I piggy backed an older app into laravel and slowly rewrote the required code.

But there is no migrate or convert, except for rolling up your sleeves and using the keyboard.

If you know php well and laravel well, you might do it in 2 or 3 days. Otherwise if learning as you go, days or weeks. I did mine in 4 evenings. But mine was not an API.

Do you need an API? A lot of questions I see here on API's, a regular web app is better suited. An API to me is just to return data that the user of the API deals with their own front end, like getting JSON data and they handle the "how to deal with it".

And most mobile apps, well I would never trust them in todays World. Most can just be mobile friendly.

But I write business apps where data is being entered. I can't see entering data all day on mobile, that's better suited for a PC and regular keyboard.

I can see a trucker checking a pickup point on his or her phone on a mobile app, but again a text would also work. As also a mobile friendly page for checking such things would work.

But just my opinion.

2 likes
n2fole00's avatar

@jlrdw

Do you need an API? A lot of questions I see here on API's, a regular web app is better suited. An API to me is just to return data that the user of the API deals with their own front end, like getting JSON data and they handle the "how to deal with it".

Sorry, looks like I was missing some important info. I was back in today and was discussing it more. It looks like they are attempting to break up the monolith app into a bunch of micro-services. I barely know what micro-services are as I've only ever dealt with monoliths. Our product is over 20 years old (it was originally an .exe) and there is a lot of code from many different periods. We recently updated to PHP 8x which was fun. The product also has its own homegrown MVC framework. At this point there is talk about using REST, GraphQL and something called gRPC which I heard for the first time today. Apparently, we can use combinations of these depending on the micro-service. We are also going to do frontend in React and have made some new hires that are good with this technology.

I guess it's going to be a question of what the micro-service is going to do in order to pick the relevant API development technology. Would be it safe to assume that Laravel can interface all of these well? The reason we are interested in Laravel is that all of us backend devs have been doing PHP for years.

Thanks.

jlrdw's avatar
jlrdw
Best Answer
Level 75

@n2fole00 You probably don't need micro services neither.

A doctor's office has to look up lab results from a lab. That would be a micro service. Pulling in that data from the lab.

Just example.

But exactly what is this software you have?What does it do.

Also see https://laracasts.com/discuss/channels/laravel/microservice-architecture read over whole post.

Good past post on the topic. There are more, just do a search.

To search in depth see https://laracasts.com/discuss/channels/guides/searching-laravel-forum

1 like
n2fole00's avatar

@jlrdw

But exactly what is this software you have? What does it do.

It's SAAS management for logistics companies and driving schools (2 separate products). It has a lot of different modules like employee management, timetable scheduling, HR recruitment, e-Learning, vehicle registries, equipment registries, newsletters, messaging etc...

Thanks for the links. I will dive in.

jlrdw's avatar

@n2fole00 You should have no problem doing a SaaS in laravel.

And some of the data if needed can be pulled in via an API still.

The one thing I like about laravel is it is very flexible.

Please or to participate in this conversation.