PHP For Beginners, Ep 39 - Write Your First Middleware
HTML-код
- Опубликовано: 12 сен 2024
- 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
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!
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.
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 ❤
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 💖
Guys more videos are on their website, link is in description
Thx :)
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.
I hope you didnt give up, i am waiting for the next steps.
Awesome series, just wondering if more episodes are coming out or is the end of the series ?
No ChatGPT can deliver a course like this. We need him continue. Let us cheer him up!
I like the longer form videos. Thank you for another good video!
I am eagerly waiting for the next videos in the series!
Is this the last one ?
It would be awsome, another video with php units tests
This is last free video? Laracast Ep40 for subs...
Can wait....I’m loving this tutorial from Jeff..
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.
Can't thank enough for this lesson.
finally please implement middleware system in your router
Awesome series 👍. Kindly create a video on phpstorm and customization
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?
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.
Can we translate this video langauge from English to hindi
very good series, will it continue?
why i didn't I find this type of content when I learned PHP 6-7 years ago .. Thanks, Jeffery
Where did you learn php 6?
@@TheRafark i did not mention php 6 any where i wrote 6-7 years (a period )
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.
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.
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)
great video!
it clearly explains the topic.
What php version does this series target?
Hello, if I wanted the controllers to be a class, what would be the best way to do it?
Can you refactor the code to implementing
PSR-7 interfaces for HTTP requests and responses.
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.
Check out Programing with Gio
ruclips.net/p/PLr3d3QYzkw2xabQRUpcZ_IBk9W50M9pe-
Fantastic video thanks a lot
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 !
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).
@@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())`.
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
what is your editor's font family
Hi Jeffrey, what editor theme you are using?
Love the lesson
Great
Hi, any news when we will get a new video ???? thanks
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
nice one. thanks.
Wow, it's over, after everything...
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?
Short answer is 'no'
@@ihorchyshkala6325 thanks. Is it mainly because Core\Middleware\Middleware does not return the instantiated object? A factory should return an object, right?
@@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
What PHP IDE are you using? thank
PHPStorm.
Building something like laravel, slowly :P
Awesome
thanks bro
can I get the source code of this project?, that would help me
Hey Jeffrey, I want to support you with Spanish Subtitles.
waiting for EPS 40...:
I think this is too advanced for a beginner