1

After coding for a couple of years, I have implemented many different software services into applications I was coding, using API documentation that software owner has provided. And I thought that was all about APIs I need to know, that it's just a way to make to software services communicate with each other.

But now I got a task to create an application, I wont go into detail, but let's say it just needs to implement CRUD operations and that it should use Vue on front and Laravel on back. And in the explanation of a task it is mentioned that I should use REST API for triggering those operations. And that's the part that confuses me!

Since I have never created an application from scratch, I was only working on already stable applications, fixing bugs and implementing new functionalities (and I guess this is the what it looks like for the most of the people who work in big companies today), and that's why I thought that those two frameworks (Vue and Laravel) have already implemented REST APIs since they can communicate between themselves.

Why am I specifically asked to use REST API to trigger those operations? Is there any way other than using an API to make front communicate with back (even I am using frameworks already)? If not, do they want me to create my REST API for communication and not use the one that is already provided by frameworks? I am confused, why did they mention to use REST API as if it wasn't default option, something that shouldn't even even be questionable, just an expected behavior.

4
  • Forgive me, but it sounds a little bit like you're over thinking things (in a nice way). Out-of-the-box, Laravel offers the ability to create a RESTful api with the various helpers and default features that it has, however, IMO, there are many people that don't actually follow these practices. With Laravel you don't have to follow REST for the framework to work. One of the reasons you're probably getting asked specifically to create a RESTful api is just for the sake of being explicit. Commented Feb 11, 2020 at 9:03
  • Let me make this clear just to see if I have understood you. Even they have mentioned that, it's not a big deal. I should make that app as I usually do, make it work, save into DB what is needed and read from DB and that would be it, no hidden intentions. It means sending POST and GET requests, and handling them in Controllers in the back. The app is not as easy as I represent it here, I basically need to create RisiKo strategy board game (not sure if you know what that is), but since it isn't the point of this topic I haven't described it in question. Commented Feb 11, 2020 at 9:14
  • It might be worth giving this a watch: youtube.com/watch?v=MF0jFKvS4SI Commented Feb 11, 2020 at 9:31
  • @Rwd Thank you very much. I am just still a bit insecure about this topic, since I have recently graduated and professionally working for just two and a half years. I will watch this video, thanks again Commented Feb 11, 2020 at 9:36

2 Answers 2

5

why did they mention to use REST API as if it wasn't default option

For many years, offering an API in the backend for JS frontend consumption was not the default option. Traditional "round trip" applications use a form that submits to the server with a full page refresh, and I'd hazard a guess that most web applications live today still work like that.

With the advent of Vue, React, Angular etc, there is an expectation that fetching data and sending data is done via APIs in an AJAX operation. This gives applications a more seamless feel, and they're faster, since only a relatively small amount of data needs to be sent or received.

In small Laravel/Vue applications, the frontend and backend are often in the same repo, and are deployed together as a single unit. However, as the size and complexity of an application increases, there is value in splitting up these pieces into microservices, which can be deployed separately, without tricky system dependencies complicating the deployment pipeline and sign-off process. Using an API lends itself well to that approach.

Indeed, as the backend increases, the API is not one service, but several, split by process area (e.g. user, sign-up, checkout, dashboard, etc).

Do Laravel and Vue always use ... APIs to communicate?

So, to answer your main question, you don't have to use APIs/AJAX with Vue and Laravel. You can still use standard HTTP forms and redraw the whole screen if you want.

Do Laravel and Vue always use RESTful APIs to communicate? [my emphasis]

Another way of interpreting the question is that perhaps you have received instructions from someone who was differentiating a REST API from a different kind of API. On the web, GraphQL is becoming more popular. Server-to-server, SOAP (XML) used to be very common, and is still in use in many enterprises.

Sign up to request clarification or add additional context in comments.

Comments

0

FOA, The gap is not going to fill "ASAP" because it requires domain knowledge that you are missing. And yes RESTful API is the best way unless you want multi-dimensional communication across multiple platforms.

1 Comment

Agree, but even without that knowledge I still feel like I am able to do many things and that I can continue my career progress without learning those basics. But it just doesn't feel right! Recently I had a task to implement DocuSign and also DigitalOcean, and app my company is distributing is not a small one, and it was pretty complex to implement in many different processes which already existed. AndI did it, truth saying, with the help of documentation, but still! I just wanted to make clear what I am talking about, I am not bragging. I really need help to understand above mentioned.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.