A more difficult subject to get into, since the php doc itself that you showed at the start of the video, is not very explanatory or clear about what attributes are and how they work. After seeing this lesson through and making the effort to code along with you I am now confident that I understand it enough to be able to use it. What made it clear for was that you showed that Attribute is just another class you can use and extend by creating your own Attribute classes. In the end it didn't seem difficult anymore and that shows me you're a great teacher. Thanks, Gio. Top job.
I was planning on buying a PHP course on udemy because I want to enhance my php knowledge. I'm a laravel developer and I feel like I already forgot the most part of pure php. I'm glad I found this series, and its FREE!! Thank you!
This whole tutorial playlist is outstanding. Learning a lot of things from you. Thank you !!! Would you make a video on when to use a framework , If the problems can be solved with vanilla PHP then is it worth to do it with framework? I know framework increases the development speed. But using it for smaller projects ? What are your opinions I would love to hear it.
Thank you 💙. Yes I'll make a video about that, can't give an exact time but towards the end of the series probably. My opinion is that unless the app is very small, using a framework will only speed up the work. I personally use Laravel for pretty much everything.
Wow, this one was pretty cool. I'm like seeing how we are advancing and yet you always seem to say that it can't be used in production... and I'm like, men there must be a ton of things to learn. I followed and have updated my router class. Thanks Gio. Awesome. I'm moving on...
Its not about learning ton of new things, its that this codebase is for education only, it lacks some important features that you would get from a full scale framework like Laravel or Symfony.
@@ProgramWithGio Ok. I think when I start looking into these frameworks I'll understand more of what you are saying. Notwithstanding, I'm truly learning alot
Thank you. I don't know everything by heart. A lot of research & preparation goes into each video, for example this video took me over 15 hours to make including editing.
Bro, i have one problem. At timestamp 12:23, I set the attribute "#[Route('/examples/generator')]". This works fine when the url has "/examples/generator" but fails when the url has the ending "/" like "/examples/generator/". I tried defining 2 attributes with the second one having the ending "/" and yet it failed stating i cannot have duplicate attributes. How do i address this problem?
@@ProgramWithGio Bro, the problem resolved itself when we defined the attribute as repeatable. Then i defined 2 routes. It worked. But the trimming the trailing slashes would be a better option. Tq so much.
Amazing video as always!!! Please could you create a version two of this video with parameters. It's something i just can't get my head around. Some store it in a $request->getParams(), others have it public function($param1, $param2) etc. Would be extremely helpful. Thankyou!!!! :)
@@ProgramWithGio Yes i saw that video too. Sadly it didn't help me learn the underlying technology in how dynamic routers with parameters work. Thanks tho :)
Hello, you make really great videos and I look at them with great enthusiasm. But one thing I miss here, namely: independent of a 3rd framework (such as Slim), how could you form a group here with the router class? I lack this here and also the know-how for it. I would be very happy if you could also make a separate video for this. Thank you in advance.
@@ProgramWithGio Thank you, I'm really looking forward to it. Do you know roughly how long it might be according to your calendar? Because then I can explicitly adapt to it.
@@MrLion22 no idea honestly, I'm pretty swamped right now with work and videos. Gotta finish PHP series and then Laravel. So can't give you a rough ETA on it unfortunately
@@ProgramWithGio OK, I can understand that. Then I'll just let myself be surprised and just wait and see. Hope it comes out soon. Thank you and for the quick reply ;-)
RegisterRoutesFromControllerAttributes has a nested loop it can be very slow if you have many routes + many http requests. This method is called in every http request right?
gI have made a conditional listing in this coding, but what I want to do is to find the selected data from the database and have it listed, for example, when the pediatric service is selected, the patients hospitalized in the pediatric service will be listed.
What I want to do is to list the data in the selectbox, whichever is selected, from the database. for example child service is selected in selectbox I want to list the patients treated in the pediatric service to the screen.
For simplesity and perfermance, In this case of routing I prefer to include a config file return array of all routes and merge it with array variable in the Route::class
@@ProgramWithGio Yes, suppose we have a folder named routes contains: web.php , api.php and admin.php We can load it easy using this loop: foreach (glob(__DIR__ .'/routes/*.php') as $route) { require_once $route; }
Because route is defined in attribute & the method name is there on the controller method definition, keep watching & at around 12:00 you will see multiple methods within controller
What do you mean? If you mean the autocomplete part thats just the IDE. Also I have it set up so that it adds strict types to all new PHP classes created within the IDE
If you want to make custom attributes & functionality then yes. If you want to use built in attributes or attributes that come with frameworks/package then not really
@@codewithsheikh2805 there are other topics you should be familiar with before moving into frameworks. Attributes isn't really necessary for that. Best way to know is to start the framework and if you get stuck or don't understand something, then learn about that specific topic and do it in parallel.
Can we generate getters & setters functions for properties using Attributes? Ex: #[Getter] #[Setter] private $somePropertyName; This should generate the following functionality: getSomePropertyName(){...} setSomePropertyName(){...}
Not sure to be honest. You can use IDEs for that to generate getter & setters. If you mean dynamically then you can use magic __get & __set methods. Not sure I understand the use case.
your job is very great. appreciated you. but a lot of things we not understand. if I compare with other programmers, you are tackle a problem with complex method. I don't know if I have the basic skills of php or your method is complex? please explain. but don't mind bro
I'm not sure what you mean. What problem did I tackle with complex method? Attributes is not complex, it's a feature that I'm explaining and providing a usecase. If it seems complex then you can start from first section maybe, are you following the series from the beginning? Note that this is third section of the series which is advanced PHP, so if it seems hard I would advise to watch the series from the beginning. There are a lot of videos in first & second sections
I wish you could have done a separate video without all the Route stuff. This is for people whom find this and just want to use Attributes. Found one ua-cam.com/video/oSo4xbP6ZYo/v-deo.html&ab_channel=GaryClarke
Well, in this playlist the Route part fits in nicely. You can use Attributes for many different scenarios, Routing is one of them & a good example as well
This is a anti-pattern way of programming. Use interfaces for routable controllers instead and register it by calling the interface method. Much clearer. Using the reflection class is never a good way of programming.
I respectfully disagree. Don't see this as antipattern, most popular frameworks use both attributes/annotations & reflection API so not sure what you mean?
@@ProgramWithGio My main point is that there are other and clearer options. I observe that in practice the Reflection API is used too often and incorrectly, resulting in cluttered and poorly maintainable code. Please always try to find another solution first, typically with interfaces.
@@bernhardd626 we didn't use it wrongly or poorly in this video. Reflection API exists for a reason and Attributes is a great feature which you can't really use without Reflection API. Doing routing via attributes/annotations is a very common practice & there is absolutely nothing wrong with it. As I said before most popular frameworks utilize Reflection API the same way and use it pretty often in their source.
A more difficult subject to get into, since the php doc itself that you showed at the start of the video, is not very explanatory or clear about what attributes are and how they work.
After seeing this lesson through and making the effort to code along with you I am now confident that I understand it enough to be able to use it.
What made it clear for was that you showed that Attribute is just another class you can use and extend by creating your own Attribute classes.
In the end it didn't seem difficult anymore and that shows me you're a great teacher.
Thanks, Gio. Top job.
I'm really happy to hear that, thank you so much 💙
I was planning on buying a PHP course on udemy because I want to enhance my php knowledge. I'm a laravel developer and I feel like I already forgot the most part of pure php. I'm glad I found this series, and its FREE!! Thank you!
Happy to hear, thank you 💙
For being an awesome technical teacher!
Thank you so much 💙💙💙
This course is extremely useful if someone would like to dive right into PHP. Thanks a million!
Thank you 🙏
Quality, modern PHP stuff, keep it up.
The grind is real.
You got this!
This is the best attributes explanation! Thank you for sharing!
Glad it was helpful, thank you
Thanks!
You're welcome & thank you!
i love you man !!! thank you so much
This whole tutorial playlist is outstanding. Learning a lot of things from you. Thank you !!!
Would you make a video on when to use a framework , If the problems can be solved with vanilla PHP then is it worth to do it with framework? I know framework increases the development speed. But using it for smaller projects ? What are your opinions I would love to hear it.
Thank you 💙. Yes I'll make a video about that, can't give an exact time but towards the end of the series probably. My opinion is that unless the app is very small, using a framework will only speed up the work. I personally use Laravel for pretty much everything.
@@ProgramWithGio Laravel
Wow, this one was pretty cool. I'm like seeing how we are advancing and yet you always seem to say that it can't be used in production... and I'm like, men there must be a ton of things to learn. I followed and have updated my router class. Thanks Gio. Awesome. I'm moving on...
Its not about learning ton of new things, its that this codebase is for education only, it lacks some important features that you would get from a full scale framework like Laravel or Symfony.
@@ProgramWithGio Ok. I think when I start looking into these frameworks I'll understand more of what you are saying. Notwithstanding, I'm truly learning alot
You just described the topic perfectly 👌🏻🙏🏻
Thank you
Really well made video 👏
Thank you 🙌
im really amazed the information you have how did you get all these knowledge please !
Thank you. I don't know everything by heart. A lot of research & preparation goes into each video, for example this video took me over 15 hours to make including editing.
@@ProgramWithGio
i see that im just really amazed your channel deserves alot and also if possible do a laravel short videos and tips.
hmm, you are awesome.
other speakers tell about his vacation, mood, dogs and at the end about php attributes )))
thank you
heh, thank you 🙌
Quality stuff! Thanks!! :)
Glad you enjoyed it, thank you
Thanks you very very much! you are the best)
You're welcome, thank you 🙌
Bro, i have one problem. At timestamp 12:23, I set the attribute "#[Route('/examples/generator')]". This works fine when the url has "/examples/generator" but fails when the url has the ending "/" like "/examples/generator/". I tried defining 2 attributes with the second one having the ending "/" and yet it failed stating i cannot have duplicate attributes. How do i address this problem?
You could modify the Router class (resolve method) and trim of any trailing slashes
@@ProgramWithGio Bro, the problem resolved itself when we defined the attribute as repeatable. Then i defined 2 routes. It worked. But the trimming the trailing slashes would be a better option. Tq so much.
Realy how Could this playlist are for free!!!! God save you . And realy we are apperciate your effort thaks alot
You're welcome & thank you
Amazing video as always!!! Please could you create a version two of this video with parameters. It's something i just can't get my head around. Some store it in a $request->getParams(), others have it public function($param1, $param2) etc. Would be extremely helpful. Thankyou!!!! :)
Thank you 🙏. We use SlimPHP later in the series which comes with built in router and param support so you won't have to build it from scratch
@@ProgramWithGio Yes i saw that video too. Sadly it didn't help me learn the underlying technology in how dynamic routers with parameters work. Thanks tho :)
Hello, you make really great videos and I look at them with great enthusiasm. But one thing I miss here, namely: independent of a 3rd framework (such as Slim), how could you form a group here with the router class? I lack this here and also the know-how for it. I would be very happy if you could also make a separate video for this. Thank you in advance.
Thank you, and thanks for the suggestion, I'll add it in my list of videos to make 🙌
@@ProgramWithGio Thank you, I'm really looking forward to it. Do you know roughly how long it might be according to your calendar? Because then I can explicitly adapt to it.
@@MrLion22 no idea honestly, I'm pretty swamped right now with work and videos. Gotta finish PHP series and then Laravel. So can't give you a rough ETA on it unfortunately
@@ProgramWithGio OK, I can understand that. Then I'll just let myself be surprised and just wait and see. Hope it comes out soon. Thank you and for the quick reply ;-)
RegisterRoutesFromControllerAttributes has a nested loop it can be very slow if you have many routes + many http requests. This method is called in every http request right?
Yes, there needs to be a caching layer for a more optimal solution. This is just an example demonstrating how attributes can be used for routing.
gI have made a conditional listing in this coding, but what I want to do is to find the selected data from the database and have it listed, for example, when the pediatric service is selected, the patients hospitalized in the pediatric service will be listed.
I can't really help you without knowing what the problem is or having access to the code.
@@ProgramWithGio let me assign the code
What I want to do is to list the data in the selectbox, whichever is selected, from the database.
for example child service is selected in selectbox
I want to list the patients treated in the pediatric service to the screen.
For simplesity and perfermance, In this case of routing I prefer to include a config file return array of all routes and merge it with array variable in the Route::class
For sure, its fine if you have a few routes but as you add more routes then extracting it to a config routes file is the better way. Great tip 👍
@@ProgramWithGio
Yes, suppose we have a folder named routes contains: web.php , api.php and admin.php
We can load it easy using this loop:
foreach (glob(__DIR__ .'/routes/*.php') as $route) {
require_once $route;
}
What if controller class have more than one method , how $method will get the right method of controller class , video reference 10:44
Because route is defined in attribute & the method name is there on the controller method definition, keep watching & at around 12:00 you will see multiple methods within controller
@@ProgramWithGio Got it , Thanks Sir
Hey Gio. I see that you declare strict types by doing something on "
What do you mean? If you mean the autocomplete part thats just the IDE. Also I have it set up so that it adds strict types to all new PHP classes created within the IDE
@@ProgramWithGio yup, I mean IDE set up that adds strict types to all new PHP classes. What do you use for that?
@@bakosyyit's just a setting on PHPStorm. I believe it's a PHP stub template file. You can Google it and find how to edit it on PHPStorm
Can we expect "Laravel the right way" with some awesome project ?
🙂. I don't know yet, after this my plan is Laravel & Shopify. We'll see
Do i need to understand reflection Api before I can use Attributes
If you want to make custom attributes & functionality then yes. If you want to use built in attributes or attributes that come with frameworks/package then not really
@@ProgramWithGio ok so I'm beginner in php do i need to know about this before i can start learning some framework?
@@codewithsheikh2805 there are other topics you should be familiar with before moving into frameworks. Attributes isn't really necessary for that. Best way to know is to start the framework and if you get stuck or don't understand something, then learn about that specific topic and do it in parallel.
@@ProgramWithGio thanks bro.
Sooooo, #Attributes are for PHP what @Decorators are for Typescript ?🤔🤔🤔🤔
I don't know Typescript but from quick Google it seems yes
@@ProgramWithGio You seem like the type to like type hinting so I suggest that you give it a try 👍
@@ntdash2153 Thanks. I will when I have the need for it, I mainly work on back-end currently.
do you think about making a laravel course too? also thank you for the videos ur a god
Thank you. After PHP series is over I'll be doing more Laravel content, not a full course like PHP but more project oriented
Can we generate getters & setters functions for properties using Attributes?
Ex:
#[Getter]
#[Setter]
private $somePropertyName;
This should generate the following functionality:
getSomePropertyName(){...}
setSomePropertyName(){...}
Not sure to be honest. You can use IDEs for that to generate getter & setters. If you mean dynamically then you can use magic __get & __set methods. Not sure I understand the use case.
@@ProgramWithGio Isn't using __get and __set method bad practice?
@@codewithsheikh2805 depends on the use, there are pretty good usecases for it
Will you cover AJAX?
Not directly since it's not a PHP thing. Might use it in a project though
your job is very great. appreciated you. but a lot of things we not understand. if I compare with other programmers, you are tackle a problem with complex method. I don't know if I have the basic skills of php or your method is complex? please explain. but don't mind bro
I'm not sure what you mean. What problem did I tackle with complex method? Attributes is not complex, it's a feature that I'm explaining and providing a usecase. If it seems complex then you can start from first section maybe, are you following the series from the beginning?
Note that this is third section of the series which is advanced PHP, so if it seems hard I would advise to watch the series from the beginning. There are a lot of videos in first & second sections
its like python decorator.. also like flask
Maybe 🤔. I'm not familiar with Python decorators or flask so not 100% sure.
Porque no ponen así pero en español
Not sure what you mean
👍
🙌
pleplease can you help me
What do you need help with?
I wish you could have done a separate video without all the Route stuff. This is for people whom find this and just want to use Attributes. Found one ua-cam.com/video/oSo4xbP6ZYo/v-deo.html&ab_channel=GaryClarke
Well, in this playlist the Route part fits in nicely. You can use Attributes for many different scenarios, Routing is one of them & a good example as well
like
Thank you
This is a anti-pattern way of programming. Use interfaces for routable controllers instead and register it by calling the interface method. Much clearer. Using the reflection class is never a good way of programming.
I respectfully disagree. Don't see this as antipattern, most popular frameworks use both attributes/annotations & reflection API so not sure what you mean?
@@ProgramWithGio My main point is that there are other and clearer options.
I observe that in practice the Reflection API is used too often and incorrectly, resulting in cluttered and poorly maintainable code.
Please always try to find another solution first, typically with interfaces.
@@bernhardd626 we didn't use it wrongly or poorly in this video. Reflection API exists for a reason and Attributes is a great feature which you can't really use without Reflection API. Doing routing via attributes/annotations is a very common practice & there is absolutely nothing wrong with it.
As I said before most popular frameworks utilize Reflection API the same way and use it pretty often in their source.
Hello Gio! Do you have Discord / Are you going to start one? I'd love to join it and learn from a very experienced programmer like yourself.
Hello. Yes I have a discord, though I am not very active on it. You can find the link in channel about page.
Was about to ask the exact same Q! Been looking for a good PHP community. Have had a great experience in Kevin Powell's for the front end stuff.
Do you have instagram
whatsapp
Nope. You can reach me on Twitter