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?
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:
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.
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