Multitenancy in Laravel: Migrations, Testing, and switching tenants

preview_player
Показать описание
In this video, we discuss how we can achieve multitenancy in Laravel using the database-per-tenant approach. We cover:

- Managing multiple DB connections
- Migrating & seeding tenants & admin databases
- Running tests against tenant & admin databases
- Connecting to the correct tenant on requests/jobs

Here's a link to the example application:

Some packages that provide multitenancy:

Tom Schlick's Talk at Laracon US 207:
Рекомендации по теме
Комментарии
Автор

Thank you so much! This is the most important Laravel video I’ve ever watched.

bernardonigbinde
Автор

Great video! There aren't too many great videos about multi-tenancy and how to build one from scratch. I would love to see part two that looks at making rest of the Laravel tenant specific like you mention the console commands.

juhavehnia
Автор

I don't do backend or even PHP, I just enjoy learning from your videos

OsamaQarem
Автор

Thank you Said for talking about Multinenancy. Would love more videos from you on scaling Laravel.

TareqHasan
Автор

You Sir, are a gentleman and a scholar - thank you for posting this very helpful video!

narayanramchandani
Автор

Wow! This is the best explaination I've seen of this!

The scenario I've come accross is that all users login at the same url, with the users table in the Landlord database. The user can only belong to one tenant, and so has a tenant_id on the user.

NathanBudd
Автор

I had some difficulties running the worker. In config/queue.php I found

'database' => [
'driver' => 'database',
'table' => 'jobs',
'queue' => 'default',
'retry_after' => 90,
],

and added:
'connection' => 'landlord',

Now everything is going into a central queue instead of independent tenant queues, and I can process all items in the queue via `php artisan queue:work --tries=1` -- besides that, everything was really straight forward to port over. Thanks again!

kedotdev
Автор

One approach I took is to use table prefixes for tenants. This saved me some provisioning work when it comes to creating new databases while onboarding a new tenant.

kyjan
Автор

Thank you so much for the video. So useful for me. I am developing a SAAS application.

alemran
Автор

Amazing video 🙌🏻🙌🏻🙌🏻. Thank you so much !!! Really clear and useful. There is so much to learn from here. All the different functions and config structures. Very well explained and demoed 🙏🏻🙏🏻🙏🏻

konstantinkrumov
Автор

Great video Mohamed! All very well put, it will definitely help to ease the overcomplicated approaches that people are using.

ryangjchandler
Автор

Great video. Great explanation. And very complete. Thanks for including the testing too.

kevinbatdorf
Автор

Thank you so much for your video, I needed to learn about this, I really appreciate your dedication. Hug from Brazil

rodolfo-w
Автор

Very thanks, I learning from your videos a lot

ahmedhdeawy
Автор

you saved my life! thanks a lot for this tutorial

nguyenvuuc
Автор

wow, great video man! thanks you explained vey well

vic_casanas
Автор

Thanks a lot for sharing this right on time :) this answer lots of queries and gives better clarity on implementation.

I would love to see more of such videos.

Wish audio was bit smooth !

ajit
Автор

Thank you so much bro. You saved a life.

salmankashfy
Автор

Going over the head, need to watch again and again

taslimsuman
Автор

would be great if you make a complete course laravel - tenant from scratch
Thank you

guillzf