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

aligajani's avatar

How do you guys structure your applications?

I have two options:

  1. Have frontend and backend in original folder structure so one project.
  2. Separate frontend and backend.

I have tried 2 in the past but I think it has to be deployed at the same time to avoid mishap. Therefore I am considering option 1, but I want to know if that is too naive. I want to learn from you all. I think with Laravel Vapor deploying assets to S3/CDN, 1 sounds very appealing to me now, so my entire app is deployed instantly without me having to maintain API codebase and Client codebase in separate project folders.

0 likes
5 replies
laracastsluvr's avatar

@aligajani

Hi there,

Currently working on a Laravel 5.8 app, that contains 2 Back-ends and 1 Front-end.

I structured it like so:

app\Http\Controllers\Public
app\Http\Controllers\Backend-1
app\Http\Controllers\Backend-2

App\Models\Public
App\Models\Backend-1
App\Models\Backend-2

routes\public.php
routes\backend-1.php
routes\backend-2.php

Folder names are not named like that obviously.

  • Have not tested this with Laravel 6.x
  • Uses 1 Laravel codebase.
  • Uses a single database
  • One location for all migrations (careful)
  • Routing needs modifications to work like that. Check RouteServiceProvider.php to configure it like this if you need separate routing for each end.

The reason I went this way was that I needed the separation. That's the only reason behind my decision.

But otherwise, all Laravel built-in functionality can work out-of-the-box with this structure. All sub-folders within App can be separated into their own "namespace"

1 like
aligajani's avatar

I was particular discussing the frontend and backend separation.

ekrist1's avatar

Haven't testet this approach myself, but I like the concept of using Vue, Laravel and Passport in one project. I guess you could switch Vue with Nuxtjs also. Take a look at this GitHub project: Laravel-Vue-Passport

jekinney's avatar

As always depends on current patterns, size, and deployment strategy. No one app is like another.

The size I mean more of a physical scale. 300 models? 10 models? Using a pattern can dictate that too Using TDD may dictate too.

A strategy is where is the backend is in relation to front end? Many time using Vue, devs keep completely separate for apps and other API stuff. I do, and use just an api.

Also what feels good? I personally rather click a bit into folders then scroll huge file.

aligajani's avatar

I have decided now that with Laravel Vapor up and running, I will be keeping my backend and frontend in the same folder. API will be still stateless, frontend will still be consuming JWT auth. All same stuff but same folder, utilising the power of atomic deployments with S3/CDN assets working out of the box.

If my project scales and I bring more team members, I will seperate it to api.project.com (api) and app.project.com (client). There's nothing wrong with this approach given ChipperCI has also rolled out.

Please or to participate in this conversation.