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

laracastsluvr's avatar

Multiple laravel codebases and user tables

Hi there, Laravel friends!

Is it possible to have 3 Laravel codebases share 1 database, but each with each own users? Those separated users should be able to access only the front-ends of each codebase they belong to.

Why 3 codebases and 1 Database, one might ask? Maybe it's stupid, but I like to treat each as a separate project.

The plan is to have

  • 3 separate git
  • 3 separate servers
  • 1 separate server for the database
  • 1 domain for the publicly accessible codebase
  • 2 subdomains for the 2 back-offices (the other 2 codebases).

I'd like opinions and suggestions of people with experience in large projects. Am I adding complexity by developing the project this way? I'm planning to develop it up to a certain point and hire 3 devs to assign each a codebase to continue the work together with them.

0 likes
7 replies
Snapey's avatar

Why have one database?

Is some of the data shared?

or do you mean one database server

If you must have one database.

  1. Have a seperate Laravel code base for migrations. Make sure all devs have to use that codebase to create migrations.

  2. Use a column on the user table to indicate which system they are authorised in. Bear in mind that you will have multiple users with the same email address so you will need to scope the users each time they want to register so that uniqueness is only checked in the one system.

Bear in mind that if you have shared users between applications then they will possibly become confused about passwords for each

Yes its stupid idea.

laracastsluvr's avatar

Yes data is shared between all codebases.

Yes I already make migrations only on one of the codebases

laracastsluvr's avatar

How would you approach it @snapey ?

Should I do it like the way this article describes it? https://blog.pusher.com/laravel-subdomain-routing/

I could merge my 3 laravel codebases into one. My only worry is how to keep users separated. The publicly accessible website is open to guest visitors but will have registration for visitors to create profiles on the platform. The other 2 front-ends are for administration by the staff of the company behind the platform and for customers/clients of the company. This can't be merged into one, it's a completely different output for both front-ends. Also, the admin subdomain front-end will be accessible only by the company's IP address.

laracastsluvr's avatar

So I merged my codebases into a single one, following the guide I found (linked on my previous post).

Now I need to wrap my head around Laravel's Auth and figure out user separation between the public-facing website and the two private dashboards.

I have a single Database I have a single domain with 2 subdomains

  • domain (public website)
  • sub1.domain (private dashboard 1)
  • sub2.domain (private dashboard 2)

I've almost built everything and have left Authentication for last... (yeah, yeah, stupid me)

martinbean's avatar

@laracastsluvr Why are you so hell-bent on having separate users? A user is a user. If your application has multiple front-ends, then use authorisation to restrict what a user can see based on their role.

Please or to participate in this conversation.