i have a multitenancy app.the app has one function and many domains are connected to it, what if 1 domain needs some features that requires adding extra migration file, how do yo handle it to run just that migration file for that user?
Hi, Great tutorial. I've used Tenancy with Multi Tenant & single DB. I need a functionality to ghost login my admin as a tenant user. Could you help me out with that please, if possible.
@@themsaid for queue, I've trying to know: should queue jobs be put into the centralized connection or separated for each tenant (db driver)? for redis driver maybe prefix? how to let queue workers recognize the tenant and go to the right connection of queue (if separated) and then process using right connection?
@@kingshark8848 If you plan to run a separate worker for each tenant then you can push each tenant's jobs to a separate queue and start a worker that consumes jobs from that queue only. However, the more tenants you have the more workers you'll need to run on your server which is resource consuming.
Both solutions work great. But I have some thoughts: 1. Using first approach, I must be sure the config is changed before anyone touches the session, or changes won't be applied, because of the singleton pattern. I would prefer it if laravel let me have multiple file session "connections" with different configs. 2. Using the second approach, it is better to put TannentMiddleware immediately after SessionMiddleware, to be sure session is not used in between.
Hello Mohammed thank you for your videos, can you please help me to put project laravel Multi-tenant with Multi-database : I want to create user database, for example in my system there are two user A and B. I have a master Database and two database user_a (for user A) and user_b (for user B). In master Database i have the all users information. Now what i want, when user A logged in system it access user_a database, and when user B logged in database connection should be user_b database. I will be so thankful for your help.
this doesn't seem to work in Laravel 8.83.22, my session doesn't get saved into the tenant's ID subfolder, SessionManager seems to always use the original folder
Ah! one have to manually create session directory for every tenant? @Mohamed, what about in cases where every tenant sign up/register an account themselves which means the developer doesn't know the number of tenant they have at the moment. To state clearly, what if the number of tenant is like 500 or more? Does this means the developer would have to manually create session file directory for every tenant one by one. I feel the tenant middleware approach is better though..
I suppose on user sign-up or $tenant->configure() you can make sure that the session directory exists. Maybe Laravel will create it if it does not exist also
@@themsaid yes, so I was wondering if there was a cross-domain weakness in tenants sharing the same secret app key for things like cookie and signed url encryption.
@@MarkSnape I don't think so. No tenant is supposed to know the key, same as the fact that no user is supposed to know the key in a non multitenant application.
Thanks a lot for this. It help me understand better about Laravel. Anyways, Salam Ramadhan Al-Mubarak.
Looking forward for more quality tips like these.
Amazing tutorial. Great job!
Thanks mohamed very useful content. Middleware approach is good, but for me I would implement both
I didn't know you had a YT channel. But I have been following your blogs
Happy to have you here as well :)
thanks this really helped a lot
Glad it helped :)
Amazing...
Thanks for watching :)
Really clear and concise video, thanks a lot. BTW what IDE do you use?
I'm using PHPStorm. The theme is called Night Owel.
Can we use laravel sanctum along with laravel-multitenancy?
i have a multitenancy app.the app has one function and many domains are connected to it, what if 1 domain needs some features that requires adding extra migration file, how do yo handle it to run just that migration file for that user?
this multi tenants is package which you used?
Hi, Great tutorial. I've used Tenancy with Multi Tenant & single DB. I need a functionality to ghost login my admin as a tenant user. Could you help me out with that please, if possible.
Awesome. Hope there will be cache and queue part.
Cache is covered in my next video. What concerns do you have about queues?
@@themsaid for queue, I've trying to know: should queue jobs be put into the centralized connection or separated for each tenant (db driver)? for redis driver maybe prefix? how to let queue workers recognize the tenant and go to the right connection of queue (if separated) and then process using right connection?
@@kingshark8848 If you plan to run a separate worker for each tenant then you can push each tenant's jobs to a separate queue and start a worker that consumes jobs from that queue only. However, the more tenants you have the more workers you'll need to run on your server which is resource consuming.
What package did you use for the multi-tenant? And you don't have the source code for this example?
Both solutions work great. But I have some thoughts:
1. Using first approach, I must be sure the config is changed before anyone touches the session, or changes won't be applied, because of the singleton pattern. I would prefer it if laravel let me have multiple file session "connections" with different configs.
2. Using the second approach, it is better to put TannentMiddleware immediately after SessionMiddleware, to be sure session is not used in between.
Good thoughts. It's important to not touch the session between updating the configurations or running the middleware indeed.
Hello, can you tell me how can I do the second option confirm you suggested.
I don't find the SessionMiddleware to put TannentMiddleware then
thanks
Hello Mohammed thank you for your videos, can you please help me to put project laravel Multi-tenant with Multi-database :
I want to create user database, for example in my system there are two user A and B. I have a master Database and two database user_a (for user A) and user_b (for user B). In master Database i have the all users information. Now what i want, when user A logged in system it access user_a database, and when user B logged in database connection should be user_b database.
I will be so thankful for your help.
this doesn't seem to work in Laravel 8.83.22, my session doesn't get saved into the tenant's ID subfolder, SessionManager seems to always use the original folder
Ah! one have to manually create session directory for every tenant?
@Mohamed, what about in cases where every tenant sign up/register an account themselves which means the developer doesn't know the number of tenant they have at the moment.
To state clearly, what if the number of tenant is like 500 or more? Does this means the developer would have to manually create session file directory for every tenant one by one.
I feel the tenant middleware approach is better though..
I suppose on user sign-up or $tenant->configure() you can make sure that the session directory exists. Maybe Laravel will create it if it does not exist also
Did you have to manually create the directories or would they have been created automatically? 2:56
You have to manually create these.
@@themsaid or I guess with the custom console command from the previous lesson? Thanks
Should the app key be different between tenants. Would this be another approach?
I wouldn't recommend changing the APP_KEY as it's used internally by the framework to encrypt things.
such as cookies?
@@MarkSnape Cookies, serialized closures, and signed URLs.
@@themsaid yes, so I was wondering if there was a cross-domain weakness in tenants sharing the same secret app key for things like cookie and signed url encryption.
@@MarkSnape I don't think so. No tenant is supposed to know the key, same as the fact that no user is supposed to know the key in a non multitenant application.
Mono audio?
Great tutorial and explanation!