Laravel Code Review: Multi-Tenancy, Events and Queues

Поділитися
Вставка
  • Опубліковано 4 жов 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.

  • @fajarsetiawansiagian
    @fajarsetiawansiagian 3 роки тому

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

  • @TristanBailey
    @TristanBailey 3 роки тому +2

    That was a good breakdown

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

  • @topx777
    @topx777 3 роки тому

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

  • @ryiad2010
    @ryiad2010 Місяць тому

    thank you it is very useful video

  • @heyyy4987
    @heyyy4987 3 роки тому

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

  • @TheMarvelsWorld
    @TheMarvelsWorld 3 роки тому

    This is really amazing. It helps me a lot

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

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

  • @rism8345
    @rism8345 2 роки тому

    Great review

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

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

  • @veds-art-world
    @veds-art-world Рік тому

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

  • @ayubadauda5295
    @ayubadauda5295 3 роки тому

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

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

  • @thisisthelogic
    @thisisthelogic 3 роки тому

    You're the best!

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

  • @ЮрийНазаров-ф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 роки тому +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.

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

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

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

  • @GergelyCsermely
    @GergelyCsermely 3 роки тому

    Interesting

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

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

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

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

  • @RudolfBrudersChannel
    @RudolfBrudersChannel 3 роки тому +1

    First, Thank you for content!

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

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

  • @meerachaturvedi9050
    @meerachaturvedi9050 3 роки тому

    There is no tenent.php in config

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

  • @nishantgupta1854
    @nishantgupta1854 3 роки тому

    can i get a download link for this project.

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