PHP For Beginners, Ep 39 - Write Your First Middleware

Sdílet
Vložit
  • čas přidán 7. 03. 2023
  • In this episode, we'll discuss the concept of middleware, and how it can be used as a bridge between an incoming request and the core of your application. We'll create two middleware classes to handle route authorization for guests and authenticated users. Watch this full series at phpforbeginners.com.
    Watch thousands of videos, track your progress, and participate in a massive Laravel community at Laracasts.com.
    Laracasts: laracasts.com
    Laracasts Twitter: / laracasts
    Jeffrey Way Twitter: / jeffrey_way

Komentáře • 63

  • @belalehner3937
    @belalehner3937 Před rokem +10

    This series is getting better and better with every episode. As someone hasn't noticed. JW let You learn the basic logic and techniques behind the very popular Laravel framework. It's very much worth to work with him and write the code (or maybe improve it) by your own, it's for your own benefit... And a short remark on the naming of the series: it's much more advanced than beginner level, but it's not a problem at all!

  • @prestonkhumbula1219
    @prestonkhumbula1219 Před rokem +6

    Hi Jeffrey, I hope you will see this. First I would like to express my heartfelt gratitude for the priceless contribution you have made to my programming career. I used the PHP for beginners series and I got a distinction in the exams. I once tried Laravel last year on some other channel tutorial but it quickly confused me and I quit. Today, I have completed the Laravel 5.4 series and I am moving to the next Laravel series. Words will never be enough to thank you. You have made more impact than you can even imagine..All the love from Africa, Zimbabwe to be specific.

  • @koller18
    @koller18 Před 9 měsíci +1

    Jeffrey, we hope you are doing well and just decided to take a vacation or important business came up. All the best to you, thousands of people are waiting for your return! From Russia with love 💖

  • @oheneadjei9832
    @oheneadjei9832 Před rokem

    Can wait....I’m loving this tutorial from Jeff..

  • @RazvanIacob
    @RazvanIacob Před rokem +1

    I like the longer form videos. Thank you for another good video!

  • @md.anwarhossain1179
    @md.anwarhossain1179 Před rokem +3

    Dear Jeffrey,
    This series is really very very helpful.
    I requested to you please describe about
    01. Model and
    02. Create a controller NoteController.php
    Finally, many many thanks for this series ❤

  • @Razor2k3
    @Razor2k3 Před rokem

    I am eagerly waiting for the next videos in the series!

  • @asheaven1st
    @asheaven1st Před rokem +1

    Can't thank enough for this lesson.

  • @hilalahmad4736
    @hilalahmad4736 Před rokem

    Awesome series 👍. Kindly create a video on phpstorm and customization

  • @niceKamrul
    @niceKamrul Před 11 měsíci

    I have seen your tweet on your new phpstorm course on laracast. Now, that must be great. But, we are eagerly waiting for this wonderful php course of yours. So, this is probably high time for you to concentrate on finishing this course again - if possible.

  • @hotwings9382
    @hotwings9382 Před rokem +1

    I hope you didnt give up, i am waiting for the next steps.

  • @patricktrivino4770
    @patricktrivino4770 Před rokem

    great video!
    it clearly explains the topic.

  • @MasroorHaider-dk2ch
    @MasroorHaider-dk2ch Před rokem +1

    Guys more videos are on their website, link is in description

  • @user-du6ns4ww6o
    @user-du6ns4ww6o Před rokem

    Wow, my respect, absolutely useful, I have an idea to translate your lessons into my language and we can help a bunch of people to understand php.

    • @devgaming4045
      @devgaming4045 Před rokem +1

      Can we translate this video langauge from English to hindi

  • @eduardogomez4676
    @eduardogomez4676 Před rokem

    Fantastic video thanks a lot

  • @teamaccount9320
    @teamaccount9320 Před rokem

    Love the lesson

  • @lserranoit
    @lserranoit Před 11 měsíci +1

    It would be awsome, another video with php units tests

  • @Doomw1ngs
    @Doomw1ngs Před rokem +1

    I'm considering to join your company and start learning about Laravel because I think is powerful tool to do anything. Can I ask you because I saw the "path section" on your site which is amazing btw, if something change on technology and the lectures for example "PHP for beginner " does not working as it used to be, do you update them frequently?

  • @user-hk2sl5ut7n
    @user-hk2sl5ut7n Před rokem

    very good series, will it continue?

  • @opionetics
    @opionetics Před rokem +3

    Awesome series, just wondering if more episodes are coming out or is the end of the series ?

    • @niceKamrul
      @niceKamrul Před rokem +1

      No ChatGPT can deliver a course like this. We need him continue. Let us cheer him up!

  • @bulent2435
    @bulent2435 Před rokem

    nice one. thanks.

  • @swancompany_inc
    @swancompany_inc Před rokem +1

    Thanks for the video Jeffery! Had a question about screencasts in general. Have you ever tried recording a down view of your keyboard? So people can see how you work the keyboard and mouse? Wonder if that would add any value or just cause distraction. Just a thought.

    • @edewaal97
      @edewaal97 Před rokem

      I know the software called Camtasia incorporates key presses or shortcut keys. That would be nice to show how he moves between files with his keyboard, or uses it to go to a line in the code for example. I get that's not what this course is about, but these are nice things to know. Maybe something for another series? "How to navigate quickly in phpstorm"
      But than these videos will come out slower than they already get released. I'm impatiently waiting after every one for the next.

  • @pratikbhujel
    @pratikbhujel Před rokem +2

    Is this the last one ?

  • @braintricker_soft
    @braintricker_soft Před rokem

    why i didn't I find this type of content when I learned PHP 6-7 years ago .. Thanks, Jeffery

    • @TheRafark
      @TheRafark Před rokem

      Where did you learn php 6?

    • @braintricker_soft
      @braintricker_soft Před rokem

      @@TheRafark i did not mention php 6 any where i wrote 6-7 years (a period )

  • @AtomTCP
    @AtomTCP Před rokem +1

    finally please implement middleware system in your router

  • @galihanggorojati3455
    @galihanggorojati3455 Před rokem

    Hi Jeffrey, what editor theme you are using?

  • @JACKoPL
    @JACKoPL Před rokem +2

    This is last free video? Laracast Ep40 for subs...

  • @whatamiwitnessing1003
    @whatamiwitnessing1003 Před 8 měsíci

    What php version does this series target?

  • @socialoutcast5387
    @socialoutcast5387 Před rokem

    Hi, Jeffrey it's been over 2 weeks that you haven't uploaded any video in this series please try to be consistent with this series because its my only source of learning programmning and thank you for the great work.

  • @jeremyframirezpasapera596
    @jeremyframirezpasapera596 Před 9 měsíci

    Hello, if I wanted the controllers to be a class, what would be the best way to do it?

  • @soldierbirb
    @soldierbirb Před 2 měsíci

    Could the "middleware not found" case, where you throw an Exception, be handled using an Enum? The error would be caught at the editor level (within the language server)

  • @lahoucineoldakdim7778
    @lahoucineoldakdim7778 Před rokem +1

    Can you refactor the code to implementing
    PSR-7 interfaces for HTTP requests and responses.

  • @ihorrud5088
    @ihorrud5088 Před rokem

    Awesome

  • @olaitanmichaelolanrewaju9122

    I find it hard to use my custom css styling
    Cus I don't want to use and css frameworks
    How can i go about that?
    Thanks for the tutorial

  • @alanfaruq4854
    @alanfaruq4854 Před rokem

    thanks bro

  • @martinsluters3651
    @martinsluters3651 Před rokem

    Thank you for the episode! Would it be correct to say that within Core\Middleware\Middleware class you used static factory pattern to instantiate a concrete middleware?

    • @ihorchyshkala6325
      @ihorchyshkala6325 Před rokem

      Short answer is 'no'

    • @martinsluters3651
      @martinsluters3651 Před rokem

      ​@@ihorchyshkala6325 thanks. Is it mainly because Core\Middleware\Middleware does not return the instantiated object? A factory should return an object, right?

    • @Sunil-kq9bx
      @Sunil-kq9bx Před rokem

      ​@@martinsluters3651 correct, it is not a factory because it never returns an object. A factory ussually returns an object, altough it is not common practice there are cases where a factory can return null

  • @mexantos
    @mexantos Před 10 měsíci

    If there any of your videos explain about hook, event or whatever you call it in the PHP atmosphere, and how to do it just like of this middleware or router on your video, with simple php ways not with frameworks, so we know how it works and got better knowledge about that

  • @mpavankumar6695
    @mpavankumar6695 Před rokem +1

    what is your editor's font family

  • @MuhammadFaisal-sb9yl
    @MuhammadFaisal-sb9yl Před 8 měsíci

    Great

  • @jediampm
    @jediampm Před 11 měsíci

    Hi, any news when we will get a new video ???? thanks

  • @vincentbeaulieu7553
    @vincentbeaulieu7553 Před rokem +1

    What are the advantages of using the key in the route file? Can't I just use `only->(Auth::class)` in the router file directly ? Is it to verify that the middleware exist? can we do that using my technique also? Thanks for these videos !

    • @Sunil-kq9bx
      @Sunil-kq9bx Před rokem +2

      Yes you can do it the way you described. No it is not to verify if the middleware exists. Doing it with a keyword requires the map. Your way would not require to check if the key refers to a class. But you might wanna check if the class being passed to the only method is a middleware. You could make a MiddlewareInterface and have every middleware implement that and cast the parameter from the only method to the MiddlewareInterface. If you than rename $key to $middleware and cast it to be either null or MiddlewareInterface in the resolve method from the Middleware class you could also skip the if check to throw an exception if the middleware is not found (in your case invalid class).

    • @jhnsmllr
      @jhnsmllr Před 9 měsíci

      @@Sunil-kq9bx Yes better is to create the MiddlewareInterface and simply implement `public function middleware(MiddlewareInterface $middleware): void` Method in the Router.php. Then use it on `routes.php` with `$router->get(...)->middleware(new MyMiddleware())`.

  • @KgfLikia
    @KgfLikia Před rokem

    Building something like laravel, slowly :P

  • @toanquoc506
    @toanquoc506 Před rokem

    What PHP IDE are you using? thank

  • @amanchaudhary101
    @amanchaudhary101 Před rokem

    can I get the source code of this project?, that would help me

  • @howuseehim
    @howuseehim Před 9 měsíci +1

    Wow, it's over, after everything...

  • @kansermusika2456
    @kansermusika2456 Před rokem

    waiting for EPS 40...:

  • @lserranoit
    @lserranoit Před rokem

    Hey Jeffrey, I want to support you with Spanish Subtitles.

  • @socialoutcast5387
    @socialoutcast5387 Před 10 měsíci +1

    Hi, Jeffrey it's been over 4 months that you haven't uploaded any video in this series please try to be consistent with this series because its my only source of learning programming and thank you for the great work.

  • @user-so5he3op1q
    @user-so5he3op1q Před rokem

    I think this is too advanced for a beginner