0

I am new to Laravel. I am developing an application which is going to be an Web (laravel8 + vue.js) + Mobile App (Android). Application has both backend and frontend on both web and mobile app. Which means I need routes for web application to manage backend and frontend and API routes to manage same. So, I was thinking how I should structure my code in Laravel to reduce code redundancy and what is best approach to plan my project DIR structure, routes etc.

Thanks.

1
  • Have you looked at Jetstream as a starting point? Commented Mar 24, 2021 at 3:00

2 Answers 2

0

I suggest you take a look at and consider using Laravel Breeze or Laravel Jetstream with the Interia.js & Vue.js stack. Here is the info: https://laravel.com/docs/8.x/starter-kits.

While both of these kits come with Inertia.js (Breeze only if you include it during installation), you don't have to use it and can use Axios or whatever you prefer.

These kits offer scaffolding with the routes, controllers, and views you need to register and authenticate your application's users and you should be able to easily build you API on top of either for the mobile app.

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

3 Comments

Yes, right I can do that but what I am thinking of keeping code structured, easy, clean, and avoid redundancy. For eg: Posts - Backend PostsController.php - Frontend PostsControllers.php and all the code for web and API goes into these files.
Yes this would not be a problem. With Jetstream controllers are by default located in app\Http\Controllers and you could create directories for your front end and back end controllers within this ie. app\Http\Controllers\front-end and app\Http\Controllers\back-end, then reference the appropriate controllers in your routes\web.php or routes\api.php based on your needs.
Yeah, I am following this approach, just wondering if there is better way of doing what I am trying to achieve here.
0

I used to use this:

Project

--routes

----api.php => you have API router here

----web.php => your web router

--views

----create-product.blade.php => then call to vue component --vue --create-product.vue

Comments

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.