PHP For Beginners, Ep 39 - Write Your First Middleware

  Рет қаралды 24,634

Laracasts

Laracasts

Күн бұрын

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

Пікірлер: 65
@prestonkhumbula1219
@prestonkhumbula1219 Жыл бұрын
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.
@belalehner3937
@belalehner3937 Жыл бұрын
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!
@koller18
@koller18 Жыл бұрын
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 💖
@md.anwarhossain1179
@md.anwarhossain1179 Жыл бұрын
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 ❤
@RazvanIacob
@RazvanIacob Жыл бұрын
I like the longer form videos. Thank you for another good video!
@Razor2k3
@Razor2k3 Жыл бұрын
I am eagerly waiting for the next videos in the series!
@oheneadjei9832
@oheneadjei9832 Жыл бұрын
Can wait....I’m loving this tutorial from Jeff..
@MasroorHaider-dk2ch
@MasroorHaider-dk2ch Жыл бұрын
Guys more videos are on their website, link is in description
@jakubfrei3757
@jakubfrei3757 Жыл бұрын
Thx :)
@thepianist123
@thepianist123 Жыл бұрын
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 Жыл бұрын
I hope you didnt give up, i am waiting for the next steps.
@asheaven1st
@asheaven1st Жыл бұрын
Can't thank enough for this lesson.
@braintricker_soft
@braintricker_soft Жыл бұрын
why i didn't I find this type of content when I learned PHP 6-7 years ago .. Thanks, Jeffery
@TheRafark
@TheRafark Жыл бұрын
Where did you learn php 6?
@braintricker_soft
@braintricker_soft Жыл бұрын
@@TheRafark i did not mention php 6 any where i wrote 6-7 years (a period )
@lserranoit
@lserranoit Жыл бұрын
It would be awsome, another video with php units tests
@opionetics
@opionetics Жыл бұрын
Awesome series, just wondering if more episodes are coming out or is the end of the series ?
@thepianist123
@thepianist123 Жыл бұрын
No ChatGPT can deliver a course like this. We need him continue. Let us cheer him up!
@Фанат-щ9ь
@Фанат-щ9ь Жыл бұрын
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 Жыл бұрын
Can we translate this video langauge from English to hindi
@guisande
@guisande 10 ай бұрын
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)
@jeremyframirezpasapera596
@jeremyframirezpasapera596 Жыл бұрын
Hello, if I wanted the controllers to be a class, what would be the best way to do it?
@pratikbhujel
@pratikbhujel Жыл бұрын
Is this the last one ?
@hilalahmad4736
@hilalahmad4736 Жыл бұрын
Awesome series 👍. Kindly create a video on phpstorm and customization
@socialoutcast5387
@socialoutcast5387 Жыл бұрын
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.
@alexanderrobinson5570
@alexanderrobinson5570 Жыл бұрын
Check out Programing with Gio
@alexanderrobinson5570
@alexanderrobinson5570 Жыл бұрын
kzbin.info/aero/PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe-
@Doomw1ngs
@Doomw1ngs Жыл бұрын
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?
@whatamiwitnessing1003
@whatamiwitnessing1003 Жыл бұрын
What php version does this series target?
@patricktrivino4770
@patricktrivino4770 Жыл бұрын
great video! it clearly explains the topic.
@lahoucineoldakdim7778
@lahoucineoldakdim7778 Жыл бұрын
Can you refactor the code to implementing PSR-7 interfaces for HTTP requests and responses.
@AtomTCP
@AtomTCP Жыл бұрын
finally please implement middleware system in your router
@olaitanmichaelolanrewaju9122
@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
@PawełJanczak-e6d
@PawełJanczak-e6d Жыл бұрын
very good series, will it continue?
@JACKoPL
@JACKoPL Жыл бұрын
This is last free video? Laracast Ep40 for subs...
@galihanggorojati3455
@galihanggorojati3455 Жыл бұрын
Hi Jeffrey, what editor theme you are using?
@swancompany_inc
@swancompany_inc Жыл бұрын
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 Жыл бұрын
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.
@eduardogomez4676
@eduardogomez4676 Жыл бұрын
Fantastic video thanks a lot
@jediampm
@jediampm Жыл бұрын
Hi, any news when we will get a new video ???? thanks
@mpavankumar6695
@mpavankumar6695 Жыл бұрын
what is your editor's font family
@vincentbeaulieu7553
@vincentbeaulieu7553 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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())`.
@teamaccount9320
@teamaccount9320 Жыл бұрын
Love the lesson
@socialoutcast5387
@socialoutcast5387 Жыл бұрын
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.
@mexantos
@mexantos Жыл бұрын
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
@bulent2435
@bulent2435 Жыл бұрын
nice one. thanks.
@toanquoc506
@toanquoc506 Жыл бұрын
What PHP IDE are you using? thank
@laracastsofficial
@laracastsofficial Жыл бұрын
PHPStorm.
@amanchaudhary101
@amanchaudhary101 Жыл бұрын
can I get the source code of this project?, that would help me
@MuhammadFaisal-sb9yl
@MuhammadFaisal-sb9yl Жыл бұрын
Great
@ihorrud5088
@ihorrud5088 Жыл бұрын
Awesome
@alanfaruq4854
@alanfaruq4854 Жыл бұрын
thanks bro
@dinsomnang487
@dinsomnang487 4 ай бұрын
I hope it another epesode with multi request combine in one controllers file..
@lserranoit
@lserranoit Жыл бұрын
Hey Jeffrey, I want to support you with Spanish Subtitles.
@KgfLikia
@KgfLikia Жыл бұрын
Building something like laravel, slowly :P
@kansermusika2456
@kansermusika2456 Жыл бұрын
waiting for EPS 40...:
@howuseehim
@howuseehim Жыл бұрын
Wow, it's over, after everything...
@joemart6887
@joemart6887 10 күн бұрын
My spl_autoload_register had an issue finding the files "Core/Middleware/Auth.php" and "Core/Middleware/Guest.php" since I was using the files as Jeffrey did: if($route['middleware'] == "guest") (new Guest)->handle(); if($route['middleware'] == "auth") (new Auth)->handle(); To fix this, I added "Middleware\" before them and it worked! if($route['middleware'] == "guest") (new Middleware\Guest)->handle(); if($route['middleware'] == "auth") (new Middleware\Auth)->handle(); Hopefully this helps someone! You can also add use Core\Middleware\Auth; use Core\Middleware\Guest; at the top! His IDE adds it automatically! It was so confusing!
@ابوأحمد-ث9ت4ض
@ابوأحمد-ث9ت4ض Жыл бұрын
I think this is too advanced for a beginner
@martinsluters3651
@martinsluters3651 Жыл бұрын
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 Жыл бұрын
Short answer is 'no'
@martinsluters3651
@martinsluters3651 Жыл бұрын
​@@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 Жыл бұрын
​@@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
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
PHP For Beginners, Ep 23 - Introduction to Authorization
14:21
PHP For Beginners, Ep 35 - Make Your First Service Container
19:23
PHP For Beginners, Ep 31 - Namespacing: What, Why, How
12:09
Laracasts
Рет қаралды 15 М.
The Intermediate Developer Trap
18:39
Laracasts
Рет қаралды 25 М.
Готовим Middleware в PHP
24:51
loftblog
Рет қаралды 10 М.
PHP For Beginners, Ep 15 - Make a PHP Router
18:03
Laracasts
Рет қаралды 63 М.
PHP For Beginners, Ep 25 - Intro to Forms and Request Methods
18:08
5 deadly Rust anti-patterns to avoid
13:25
Let's Get Rusty
Рет қаралды 41 М.
PHP For Beginners, Ep 50 - The Next Step in Your Php Journey
16:28
Tuna 🍣 ​⁠@patrickzeinali ​⁠@ChefRush
00:48
albert_cancook
Рет қаралды 148 МЛН