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

dmytroshved's avatar

Transitioning a Laravel App into an API Structure

Hello everyone, this question will be theoretical and there will no best prectices, but I'd like to see your point of view

I currently have a fully working application built with the TALL stack (so it’s a traditional Laravel app with server-rendered views). Now, I’d like to shift my focus towards building APIs, since that’s what I’ll mostly be working with in my job.

My question is:

  • Is it good practice to refactor a traditional Laravel app into an API, even if it’s not strictly required?

  • If so, which parts of the application are worth exposing or reworking through an API?

To be more precise, my application is about recipes (creating, browsing, storing)

  • Would you recommend pairing this with a frontend framework (Vue/React/etc.) to get the most out of the learning process?

Would be grateful for your advices

Best regards

1 like
5 replies
jlrdw's avatar

If you plan on a mobile app then you need to write the front end app.

If no mobile, why would you be concerned about the end user front end.

You would need an admin front end to add, update, etc. But normally you give instructions to end users or other companies on how to use your API, and they write their own front end.

Probably 85 percent of the users here when wanting to do an API, a regular web app that's mobile friendly is better suited.

Edit:

Have a look at the Eloquent: API Resources chapter:

https://laravel.com/docs/12.x/eloquent-resources#main-content

2 likes
tykus's avatar

Is it good practice to refactor a traditional Laravel app into an API, even if it’s not strictly required?

Don't expose anything unless there is a reason to do so. If you already have a working TALL stack application, then an API adds nothing other than new dead code.

3 likes
vincent15000's avatar

As @jlrdw and @tykus said, there is no need to create APIs if you don't need to develop a real mobile application.

If you only want to learn how to write APIs by transforming a TALL application, you will need to rewrite some parts of your application and rewrite the code for the frontend to have a better experience of coding in API mode.

You will have to :

  • secure the API, for example with Sanctum
  • create API resources
  • rewrite the controllers so that they return API resources instead of returning views
  • create all views with VueJS or React or any frontend JS framework
  • if you want SSR rendering, it's a better idea to use Nuxt / VueJS if you want to code the front with VueJS
2 likes
martinbean's avatar

Is it good practice to refactor a traditional Laravel app into an API, even if it’s not strictly required?

@dmytro_shved It’s not good practice, or a good use of your time and energy, to build features you don’t actually need, no.

If so, which parts of the application are worth exposing or reworking through an API?

The fact you’re asking this just further proves you don’t need an API, and you’re just writing one “because”.

2 likes

Please or to participate in this conversation.