Laravel Code Review: Multi-Tenancy, Events and Queues

แชร์
ฝัง
  • เผยแพร่เมื่อ 11 พ.ย. 2024

ความคิดเห็น • 80

  • @mohammadoulabi4212
    @mohammadoulabi4212 3 ปีที่แล้ว +19

    Overall the code was amazing and your review tought me like hundred new thing
    Just wow

  • @jeevachaithanyansivanandan
    @jeevachaithanyansivanandan 3 ปีที่แล้ว +2

    The way you read and breakdown the codebase is like a Symphony performance... Thankx for the video

  • @urvishpatel6105
    @urvishpatel6105 3 ปีที่แล้ว +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 ปีที่แล้ว +6

    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 ปีที่แล้ว +1

      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 ปีที่แล้ว +2

    Good review as always. And very nice work done by this developer.

  • @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)

  • @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.

  • @ryiad2010
    @ryiad2010 2 หลายเดือนก่อน

    thank you it is very useful video

  • @veds-art-world
    @veds-art-world ปีที่แล้ว

    Can you create tests for GitHub CI in multiple sub domain?

  • @hadesinferno813
    @hadesinferno813 2 ปีที่แล้ว

    How do you set your database connection for each tenant?

  •  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.

  • @fajarsetiawansiagian
    @fajarsetiawansiagian 3 ปีที่แล้ว

    thats review of code make me understand to make each other can read my code

  • @ahmad.ms96
    @ahmad.ms96 2 ปีที่แล้ว

    thanks , do you suggest a specific multi tenant package to use ?

  • @rism8345
    @rism8345 2 ปีที่แล้ว

    Great review

  • @topx777
    @topx777 3 ปีที่แล้ว

    Thanks a lot for that advices, that a good point of view for everyone

  • @TristanBailey
    @TristanBailey 3 ปีที่แล้ว +2

    That was a good breakdown

  • @heyyy4987
    @heyyy4987 3 ปีที่แล้ว

    Very Nice, and touch many ways of do it same thing.

  • @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!

  • @aytacmalkoc
    @aytacmalkoc 3 ปีที่แล้ว +6

    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 ปีที่แล้ว +13

      Thanks, damn, I miss those things from time to time. Edited the video, TH-cam is processing the changes now. Thanks for reporting, I need to be more careful.

    • @pauloamserrano
      @pauloamserrano 3 ปีที่แล้ว +16

      @@LaravelDaily Hi Povilas, I'm the author... is not problem with that.

    • @casapvadim
      @casapvadim 3 ปีที่แล้ว +2

      @@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 ปีที่แล้ว +2

      @@igbokwelaurence5882 email me. pauloamserrano@gmail.com

  • @thebollyhollymix
    @thebollyhollymix 3 ปีที่แล้ว

    Can we use fqdn example.test instead of subdomains?

  • @ЮрийНазаров-ф5ж
    @ЮрийНазаров-ф5ж 3 ปีที่แล้ว

    Hi!
    Why events? isnt it easier to use observer? and call queue from observer

  • @ayubadauda5295
    @ayubadauda5295 3 ปีที่แล้ว

    Thanks for the review, Using this pattern, is there a way we can scale up for a single tenant?

  • @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.

  • @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 ปีที่แล้ว +2

      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.

  • @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 ปีที่แล้ว +2

      Personal preference.

    • @pauloamserrano
      @pauloamserrano 3 ปีที่แล้ว +2

      @@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.

  • @TheMarvelsWorld
    @TheMarvelsWorld 3 ปีที่แล้ว

    This is really amazing. It helps me a lot

  • @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 ปีที่แล้ว +1

      Sorry I haven't worked with such projects or CSC API, so I have no advice.

  • @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!

  • @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

  • @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?

  • @thisisthelogic
    @thisisthelogic 3 ปีที่แล้ว

    You're the best!

  • @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 ปีที่แล้ว +1

      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 ปีที่แล้ว +1

      All subdomain requests come to the same Laravel installation. The application then detects which subdomain the request was for.

  • @RudolfBrudersChannel
    @RudolfBrudersChannel 3 ปีที่แล้ว +1

    First, Thank you for content!

  • @casapvadim
    @casapvadim 3 ปีที่แล้ว +1

    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 ปีที่แล้ว +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.

  • @sarangbelsare7176
    @sarangbelsare7176 3 ปีที่แล้ว

    Hello sir
    Can you please provide the code to get some help about multi-tenancy?

    • @LaravelDaily
      @LaravelDaily  3 ปีที่แล้ว +2

      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 ?

  • @alila3883
    @alila3883 2 ปีที่แล้ว

    🤙

  • @shocchosolutions6275
    @shocchosolutions6275 3 ปีที่แล้ว

    how to upload laravel app in shared hosting

    • @LaravelDaily
      @LaravelDaily  3 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

      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

  • @GergelyCsermely
    @GergelyCsermely 3 ปีที่แล้ว

    Interesting

  • @nishantgupta1854
    @nishantgupta1854 3 ปีที่แล้ว

    can i get a download link for this project.

    • @mytechschool8357
      @mytechschool8357 3 ปีที่แล้ว +1

      No Because. Its someone else property

  • @meerachaturvedi9050
    @meerachaturvedi9050 3 ปีที่แล้ว

    There is no tenent.php in config

  • @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.

  • @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.