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

joedawson's avatar

Multiple Apps within a Single App?

Hello all,

Sorry if this doesn't make sense - but I'll try and explain as best as possible.

Let's start with saying I have 1 Laravel app that we use internally at my workplace and one potentially coming soon. They're not necessarily large apps as they're just for employee usage but I want to somehow link these together.

By linking I mean; sharing the same users, the same roles, having the same assets (css, images, js etc).

Each app will still require to have it's own database as I don't necessarily want to bulk up a single database and it makes it easier to maintain (at least I think it will). They both also have their own dependencies, so I don't necessarily want to have to include these on each one - especially as these can grow and grow.

So to be clear, lets say I have an domain of: http://internal.com

When I visit this I'll be required to authenticate before anything of course - then when I am, I have a list of "apps" available to access. These two could be named foo and bar for example.

When I click either of these, I want to be redirect to either of these subdomains:

Of which I will be able to access because I'm authenticated. But at some point in the future, I would maybe like to have some apps only available to certain people with a given role.

Then in either of these apps, they'll share the same assets as I mentioned above and will be using different databases so if I want to work on either of them in the future and one of them is down for maintenance - the entire system isn't out.

I hope everything makes sense and I'm not over complicating things!

Thanks :)

0 likes
13 replies
christopher's avatar

Thats something for tenant database. So each app would have its own database within one application. There is also a package for laravel: https://github.com/orchestral/tenanti

But because you still have one app for several domains each app/domain would have the same dependencies.

martinbean's avatar

@JoeDawson What will the apps do? You’re talking in very abstract and general terms that it’s hard to advise one way or the other.

joedawson's avatar

@martinbean while I do not mind explaining what the apps do - I'm not sure it's relevant to my question?

The first is a small ecommerce app we use to keep track of our "snacks" in-house. Such as energy drinks etc so we know when to order more in.

The other is a password manager.

martinbean's avatar
Level 80

@JoeDawson It is as “apps” could be any thing, and what they do would affect things like whether sharing a database is the right approach or not.

In your case, I would say they’d be better off as single apps (they’re doing different things) and have one, common app that handles things like authentication, has common assets like style sheets and images etc.

The app would act as a “single sign-on” server, so the inventory and password manager apps—and any future apps—would authenticate against this SSO server. This way, app-specific stuff stays segregated, as I assume a snack being purchased doesn’t need to know about a password.

1 like
joedawson's avatar

Thanks @martinbean and @christopher - I'll let this thread linger for a day or so to see if anyone else can suggest any other methods of doing this before I proceed.

ohffs's avatar

I'm going to be doing something similar - we've got a few tools we use internally for IT stuff which were all hand-written (ah, raw mysql queries - I see you!). I'm eventually (ha) going to move them to laravel. I was vaguely thinking of making them packages so I could just require them and build the main 'app' out of them as components. Partly because other folk might want to use one part (say the DHCP management tool) but maybe not the license manager stuff.

Also, it's easier (and/or lazier) to have one ssl cert and just shove the apps behind /paths/ ;-)

bashy's avatar

Some sort of single sign-on system would be preferred for this type of system. Like what @martinbean suggested.

joedawson's avatar

Cheers for all the help guys, going to sit down over Christmas and come with with a plan of action. Thanks!

joedawson's avatar

I went for your solution in the end @martinbean, I came across your reply here of which has helped me greatly. Still not entirely sure how this OAuth stuff works, but I'm getting there.

Thanks!

1 like
pakogn's avatar

@JoeDawson excuse me, I'm working on something similar, I'm interested on what you decided to do to solve this problem. Even if you can explain the flow your applications follow to manage the authentication it would be great!! Kind Regards.

joedawson's avatar

Hello @pakogn,

In short, I made my own Socialite driver using @martinbean's repo here: https://github.com/yourfightsite/socialite-provider

I then installed an OAuth server using this package in my parent application using this package.

https://github.com/lucadegasperi/oauth2-server-laravel

That way, I can use the custom Socialite driver on any child applications to connect with my parent application.

I didn't manage to sort out any roles though, as I still haven't got round to finishing this but that was the general approach I went with.

1 like
pakogn's avatar

@JoeDawson Glad to see your answer,

I'm going in the same way but what about if i log out in one application... how are you going to manage this in another application to update the logged out state?

My question is in the next scenario: Like google accounts: I enter to drive.google.com, then you sign in accounts.google.com(I think as the sso server), then it redirects back you to drive.google.com, then I decide to go to gmail and I press the logout button which it sends you to accounts.google.com/logout (for example). I can't figure how to manage the logged out state to take effect in google.drive.com and in all google applications. Are they checking if the session still on every request? How do they check the session? When you log out, do they revoke the active token? What could be a good way to handle this and don't affect the app performance?

I would like to have something like this, I don't know if I'm clear with this. Let me know

Thanks for your reply. Greetings!

Please or to participate in this conversation.