Тёмный

Laravel Code Review: Multi-Tenancy, Events and Queues 

Laravel Daily
Подписаться 145 тыс.
Просмотров 37 тыс.
50% 1

Опубликовано:

 

3 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 80   
@mohammadoulabi4212
@mohammadoulabi4212 3 года назад
Overall the code was amazing and your review tought me like hundred new thing Just wow
@jeevachaithanyansivanandan
@jeevachaithanyansivanandan 3 года назад
The way you read and breakdown the codebase is like a Symphony performance... Thankx for the video
@urvishpatel6105
@urvishpatel6105 3 года назад
I learned a lot from your videos regarding code standards and all. You are doing such great work. Thank you Povilas for giving your contribution to the laravel community. Great work. Keep it up.
@AndyTalbot
@AndyTalbot 3 года назад
Can't believe this was from 3 months ago and I missed it. Looks like a great project, well done that developer. One thing I was surprised you didn't mention was the importance of using config variables rather than env ones direct, because once you go to a production environment you should really be running config:cache, at which point all the env based bits stop working.
@JamesAutoDude
@JamesAutoDude 2 года назад
Wait really? This is the first I've heard of that... Almost all projects I've came across just says to use the env file I read the Laravel docs and it says that's only to speed up the application, doesn't say it's good practice or anything
@AndyTalbot
@AndyTalbot 2 года назад
@@JamesAutoDude I think anything that has to access and read a file could be deemed slow, better to cache it to redis or something. I also found that locally on windows when running Apache, if you have a page which on load immediately performs say 2 API calls to the server. The .env file will be locked presumably by windows from the first call, and it causes laravel to return a 500 error. Only way I found to get around this locally was to cache the config. Which if you're using the file driver makes no sense, but somehow seems to resolve it.
@JamesAutoDude
@JamesAutoDude 2 года назад
@@AndyTalbot uhhh you do know that cache is reading a file right 😬 websites general are nothing but files... I'd have to disagree as I have big applications and even tried huge Laravel projects,a they were blazing fast using just the .env
@AndyTalbot
@AndyTalbot 2 года назад
@@JamesAutoDude redis isn't files is it? That's memory based I thought. But yes otherwise file based caching should in theory still be the same problem as the .env I think windows based Apache might be a bit odd and doing some kind of blocking.
@igbokwelaurence5882
@igbokwelaurence5882 3 года назад
Good review as always. And very nice work done by this developer.
@TristanBailey
@TristanBailey 3 года назад
That was a good breakdown
@ryiad2010
@ryiad2010 Месяц назад
thank you it is very useful video
@topx777
@topx777 3 года назад
Thanks a lot for that advices, that a good point of view for everyone
@fajarsetiawansiagian
@fajarsetiawansiagian 3 года назад
thats review of code make me understand to make each other can read my code
@khanalpride
@khanalpride 3 года назад
Interesting. Events/Listeners are great as well. And they focus on things where one event can be used to fire different Listeners. You said to use Job as they are queueable. But the fact is Event is only fired. And most time consuming things are done in Listeners (which are obviously queueable)
@TheMarvelsWorld
@TheMarvelsWorld 3 года назад
This is really amazing. It helps me a lot
@rism8345
@rism8345 2 года назад
Great review
@heyyy4987
@heyyy4987 3 года назад
Very Nice, and touch many ways of do it same thing.
@veds-art-world
@veds-art-world Год назад
Can you create tests for GitHub CI in multiple sub domain?
@lucchateauvert330
@lucchateauvert330 2 года назад
Super interesting, thanks for this review. I noticed in the mapTenantRoutes function a reference to subdomain and saw that the subdomain was not used in the tenant routes file to wrap the routes. My question is, where comes from the subdomain value? Thanks!
@thisisthelogic
@thisisthelogic 3 года назад
You're the best!
@hadesinferno813
@hadesinferno813 2 года назад
If you were to run a migration in a job, how would you do that? What if a job fails, how do you catch the exception and display the error.
3 года назад
09:30 line 52: should go to FormRequest->authorize (user->can('create_project') or route middleware (can:create_project) line 58, 59, 60: not needed line 61: should go to static boot of Models\Project. Something like that: static::creating( fn ($project) => $project->created_by_id = auth()->id() ); Also, it advised to pass the guard to auth() since he/she's probably implementing multi guard authentication.
@ayubadauda5295
@ayubadauda5295 3 года назад
Thanks for the review, Using this pattern, is there a way we can scale up for a single tenant?
@aytacmalkoc
@aytacmalkoc 3 года назад
Hi, you have censored the information of the person who sent the email, but the email address appears in the search bar of the browser.
@LaravelDaily
@LaravelDaily 3 года назад
Thanks, damn, I miss those things from time to time. Edited the video, RU-vid is processing the changes now. Thanks for reporting, I need to be more careful.
@pauloamserrano
@pauloamserrano 3 года назад
@@LaravelDaily Hi Povilas, I'm the author... is not problem with that.
@casapvadim
@casapvadim 3 года назад
@@pauloamserrano nice job
@igbokwelaurence5882
@igbokwelaurence5882 3 года назад
@@pauloamserrano good job man. Is the project open source or a client. There's a lot of things I'd like to learn from that codebase
@pauloamserrano
@pauloamserrano 3 года назад
@@igbokwelaurence5882 email me. pauloamserrano@gmail.com
@hadesinferno813
@hadesinferno813 2 года назад
How do you set your database connection for each tenant?
@ahmad.ms96
@ahmad.ms96 2 года назад
thanks , do you suggest a specific multi tenant package to use ?
@RudolfBrudersChannel
@RudolfBrudersChannel 3 года назад
First, Thank you for content!
@ЮрийНазаров-ф5ж
@ЮрийНазаров-ф5ж 3 года назад
Hi! Why events? isnt it easier to use observer? and call queue from observer
@enriquerobledo845
@enriquerobledo845 3 года назад
Very interesting, a course of this topic multitenancy saas, would be a very good one, i'm willing to buy the yearly membership, maybe this idea of new course can be a thing
@LaravelDaily
@LaravelDaily 3 года назад
laraveldaily.teachable.com/p/creating-laravel-saas-with-cashier-stripe I have a SaaS course, MultiTenancy is one of the lessons there, from what I remember
@devstack6420
@devstack6420 2 года назад
@@LaravelDaily Hello sir, this course including create new database like this video? thanks.
@thebollyhollymix
@thebollyhollymix 3 года назад
Can we use fqdn example.test instead of subdomains?
@alexo2537
@alexo2537 3 года назад
Is it possible to make a tutorial with multi-databases and multi-tenants but always keeping the same base URL and not putting in the URL the subdomain ? For example my domain is project.test and from project.test/login I can identify which tenant I belong to without placing a subdomain of the account.
@naviji7306
@naviji7306 3 года назад
Hi, can you please create video on laravel installation like cms WordPress and Drupal etc Configure db details etc from browser form
@casapvadim
@casapvadim 3 года назад
For database name as a question or suggestion! - How do you think, to use some generated text from backends like: project id, or timestamp, or random string ( of course validating before if necessary) Also, there is a point in 5:30 with setConnection with a project id, looks like multitenancy is custom if it's possible to take a look at that connection if there is a used multi user or everything is running under the main database user. I found a good package from spatie spatie.be/docs/laravel-multitenancy/v2/installation/using-multiple-databases but didn't check it yet sorry if I repeated some else's question and hope not to disturb you ^_^ nice job
@LaravelDaily
@LaravelDaily 3 года назад
Yes, to be honest, I would use one of the available multi tenancy packages instead of doing it manually. Probably should have mentioned this in the video.
@NathanBudd
@NathanBudd 3 года назад
What would be the differnce here between using a listener and a model observer which fires a job on create?
@LaravelDaily
@LaravelDaily 3 года назад
Personal preference.
@pauloamserrano
@pauloamserrano 3 года назад
@@LaravelDaily Without a doubt between listeners and observers is a personal preference, however I reformulated that part of the project to use queues and came to the conclusion that jobs must be used, for the simple reason that in queue, listeners are not used chaining, which sometimes caused error because the migrations listener was triggered before the database was created. With jobs and queue chains this problem is solved, because we can chain jobs and the second is triggered only when the first one finishes successfully.
@GergelyCsermely
@GergelyCsermely 3 года назад
Interesting
@aloha276
@aloha276 3 года назад
A question please, Since this project is using subdomains to get the database name, do you have any idea on how to get the right database in case we connect this project to a mobile app using a REST API ?
@aloha276
@aloha276 3 года назад
@Ahmed Safaa Thanks for your help!
@alila3883
@alila3883 2 года назад
🤙
@rizhuljanuar1618
@rizhuljanuar1618 3 года назад
Sir, know how to use the laravel telescope without migrate, because the database has been provided
@LaravelDaily
@LaravelDaily 3 года назад
Telescope has nothing to do with migrations, from what I understand. What functionality of telescope you want to use exactly?
@badeamihai
@badeamihai 3 года назад
Hi, I have a web application built on Laravel for document management with an integration with CSC API from where I get a hashed signature. I am wondering if you have a solution for adding this signature to the pdf. I don't have access to the private or public keys, they are stored in the cloud and the certificate as well. Thank you
@LaravelDaily
@LaravelDaily 3 года назад
Sorry I haven't worked with such projects or CSC API, so I have no advice.
@adityakadam2256
@adityakadam2256 3 года назад
How does it work for sub domain routing? Don’t we need to create separate DNS record for each subdomain on live servers like Route53?
@corneveldman3494
@corneveldman3494 3 года назад
You can wildcard subdomains
@DeteCT0R
@DeteCT0R 3 года назад
If you have project like this consider using cloudflare. They have php api so you can create subdomain. Wildcard is good for local testing.
@MarkSnape
@MarkSnape 3 года назад
All subdomain requests come to the same Laravel installation. The application then detects which subdomain the request was for.
@meerachaturvedi9050
@meerachaturvedi9050 3 года назад
There is no tenent.php in config
@meerachaturvedi9050
@meerachaturvedi9050 3 года назад
It has been deleted looks soo
@JamesAutoDude
@JamesAutoDude 2 года назад
How the heck do you know all of this 😭 there's so many damn files with Laravel that I constantly get confused!
@LaravelDaily
@LaravelDaily 2 года назад
Practice. A lot of practice.
@sarangbelsare7176
@sarangbelsare7176 3 года назад
Hello sir Can you please provide the code to get some help about multi-tenancy?
@LaravelDaily
@LaravelDaily 3 года назад
Which code do you need? If you want the code of that specific repository, then I can't give you that, because it's not my code and it's not public.
@igbokwelaurence5882
@igbokwelaurence5882 3 года назад
@@LaravelDaily do you have any multi tenancy tutorial available Sir ?
@shocchosolutions6275
@shocchosolutions6275 3 года назад
how to upload laravel app in shared hosting
@LaravelDaily
@LaravelDaily 3 года назад
I don't recommend shared hosting for any Laravel project.
@windigo000
@windigo000 3 года назад
i use wz.cz ... in their file manager one can unzip package. commands can be run by simple routes. BE VERY CAREFULL WITH THAT. secure everything. it's easies to migrate localy and import db struct through sql manager. there might be issue with rewrite ... check hosting q&a or ask CS ;)
@windigo000
@windigo000 3 года назад
also... run composer before upload to get rid of dev packages. you don't need them.
@poplach
@poplach 3 года назад
Make a new laravel project on local machine, then run composer require without --dev, run migrations. Then upload everything on shared hosting and export/import mysql databases separately. Here you go - everything running. The problem is only with artisan commands - you don't have access to a console - so you can't run artisan commands. Everything else runs great. Tested bagillion times. Laravel can be run on shared hosting, but I'd recommend only really small projects to run on that. Since when the time comes to update your project - it will be VERY uncomfortable to do that. Oh yeah, forgot to mention that all your QUEUED JOBS won't work at all, since the listener won't work as well. So forget about queued jobs too
@nishantgupta1854
@nishantgupta1854 3 года назад
can i get a download link for this project.
@mytechschool8357
@mytechschool8357 3 года назад
No Because. Its someone else property
@newtoys5593
@newtoys5593 2 года назад
You are the best but I don't like you have mixed to many topics in one lesson.
@simbarashemaunga5575
@simbarashemaunga5575 Год назад
Good content. However, as always you re too fast, it literally feels like you are flexing instead of actually teaching or enlightening someone.
Далее
Laravel TDD in "Live" Mode: Checkout Code Review
36:04
Multi-tenancy in Laravel
1:24:05
Просмотров 6 тыс.
Junior Code Review: Cleaning Up Laravel CRUD
14:54
Просмотров 69 тыс.
Multi-tenant Architecture for SaaS
11:07
Просмотров 116 тыс.
9 Tips for Shorter Laravel Code
10:16
Просмотров 61 тыс.
Laravel Octane & FrankenPHP 🧟
3:20
Просмотров 20 тыс.
4 Packages You Need in ANY Laravel Project
8:14
Просмотров 61 тыс.
Learnings from our multi-tenant Laravel application
9:58