MrRobot21's avatar

Laravel API for Apps and Web and Vue.js

Hi Awesome People

I'm a kinda confused about API please point me in the right direction

We want to develop an e-commerce website and Mobile apps as well with one database, my doubt is how to create a n API so that both app and the web interact with database or is there a better way to do that. What is the best architecture to achieve this

Thank you

0 likes
12 replies
katifrantz's avatar

Yea, an api is a good option in this case . Think of an api as some service that just spits out data . Therefore your web app will just consume this data, as well as your mobile app . Laravel or Lumen are the best options for such a task . You can build your web app with a framework(kind of ) like Vuejs , Angular, or any of the popular ones out there , and these will just consume data from Laravel/Lumen . https://www.youtube.com/channel/UC4gijXR8cM4gmEt9Olse-TQ . This channel might give you an idea of how things work with vuejs . Also , the mobile app will communicate with the same api .

Little stress relieving option : You might not want to build a complete SPA website , so u still can use laravel to build your web app, then create an api for your mobile app , which will simply be creating exactly the same backend app structure, but with a stateless architecture

Hope this helps .

1 like
Darival's avatar

I made a small project for a class using Ionic and Lumen, working with Ionic using html, js and css and Lumen for backend makes it feel like building a website.

1 like
MrRobot21's avatar

@maitrefrantz, @Darival Thanks for your your time really appreciate it

@maitrefrantz If i want to build a website on top of a Laravel API i need to use some front end MVC like "React.js or Angular.JS or Backbone.js" something like that right

katifrantz's avatar

Yes , you need to . I'd recommend Vuejs , because laravel recommends it , and it's its just awesome , very easy to get started with . Good Luck !

1 like
MrRobot21's avatar

@maitrefrantz Thanks a lot for your time

i just have one more doubt, how to implement the cart functionality in case os API, should i right it in Vue.js or is there any better way to do it

Thank you

WebKenth's avatar

@MrRobot21

I would recommend making your view as dumb as possible and create all the functionality serverside through your controllers/models

So all your VueJS needs to concentrate on is what should be displayed and how.

1 like
katifrantz's avatar

Hello @MrRobot21 , @WebKenth is right ... All functionality should be build in Laravel . Vuejs should just display data it gets from laravel .

1 like
MrRobot21's avatar

@WebKenth @maitrefrantz Thank you both for you response

i'm new to this laravel, and i'm confused.

what i understood from above is that i have to implement all the functionality(cart) in laravel and just tell the Vue what to display and what not. my concern is how the cart works without page refresh

Could you please point me to some tutorials or existing work or any github projects

Thank You

MrRobot21's avatar

@WildRelaxo Thanks for you time really appreciate it

can you please tell me why it is not god to implement cart functionality in Vue

Thank You

NickeyGod's avatar

@MrRobot21

I didn't mention anything about cart functionality. If you want to implement it in your Vue.js File you are free todo so. You should learn the functionality off the api of Laravel then return your data from there and then consume it in your Vue files so the page is actual reactive.

1 like
MrRobot21's avatar

@NickeyGod Thank You for the tutorial link

I think i should start with understanding Vue.js and The Laravel API Completely

Thanks for your time

1 like

Please or to participate in this conversation.