I can't believe that the duration of this video is 50 minutes. I didn't pause or skip a bit of this video. 50 minutes felt like 5 minutes. You're a good educator!
After searching for hours in multiple places for tutorials, blogs.. that explain the php attributes, you were the only one who actually explained how it works. Thanks.
Hi Gary, I just wanted to express my appreciation for your tutorials. Your explanations are clear and easy to follow, which has greatly helped me. Keep up the fantastic work!
Kinda late to the party but for any junior developers watching this video DO NOT ever let the ValidationRuleInterface create its own validator as it makes it nearly impossible to inject any dependencies to the validator class and breaks the single responsibility principle. The attribute should at most define any required arguments for the validator (for string length validation the min and max length for example) and the error message. Let the validator or validator locator / chain pair the attribute with its correlating validator. Overall great example of how to use attributes.
You Sound like Simon Allardice from Pluralsight. This is exactly what I wanted to learn. Also I was following the PHP docs. Today have learned how to read them properly too. By clicking the returned type then reach for it's properties. Thanks Clarke
Great video. Just wanted to point out though that 'use' does not actually import anything. It just tells PHP what fully qualified name to locate if that class is called (and now functions). Minor point, but ppl get this confused so much. 🙂
Another great video from you. Thanks for this video though i'm gonna watch it later. I'm very grateful from your php oop course video (i watched your 2 & 3 hour videos), now i understand the oop concept completely.
Great & Great ❤❤ just I was thinking if it could be more straight forward by just having a validate method inside the Rule class itself instead of getValidator() and then call another class to do the validation. I mean the rule should define the validation logic itself and other wise it might not be actually a Required Rule !?
@@GaryClarkeTech in my opinion to do it, it's better because you can find all points with mixed declaration for later refactor and to pass PhpStan check.
Please how can we use Attributes to protect say, database credentials used to define a PDO connection. Exceptions thrown even within a try/catch, would reveal sensitive information!
@@GaryClarkeTech Maybe, Gary, you can illustrate how. Because, I followed the link you gave us. It seems that the Sensitive Parameter Attribute is to be used in the function/method definition NOT when Calling the function/method. Should I extend the PDO Class and override the Constructor's handling of the Password, etc?
No..I wouldn't extend PDO, create your own Connection class which has PDO as a dependency. Then you can mark params on that class as sensitive and throw your own custom exceptions from that class if / when PDO exceptions are thrown and caught.
The way I figure stuff like this out is to start simple. So just create simple class with one method and a couple of parameters and add the SensitiveParameter attribute to it to get a feel for it. Then take what you know and apply it to your own code. Here's a very simple Connection class which I created for the Test Driven PHP course: github.com/GaryClarke/pest-tdd/blob/main/src/Database/Connection.php
I can't believe that the duration of this video is 50 minutes.
I didn't pause or skip a bit of this video. 50 minutes felt like 5 minutes. You're a good educator!
Thanks a lot..appreciate the kind words...hope I didn't make you late for anything!
After searching for hours in multiple places for tutorials, blogs.. that explain the php attributes, you were the only one who actually explained how it works.
Thanks.
You're welcome. Glad I could help!
Full explanation is in the PHP docs also..
You are a legend for any Wordpress/PHP developer. Thank you so much :D
You're welcome...thanks for watching!
Thanks, Gary for taking the time to explain attributes. This tutorial is simple to follow for all levels of PHP developers.
You're very welcome!
One of the best PHP tutorials I have seen so far. Very well explained!
Thanks for watching...I appreciate the kind words!
Hi Gary,
I just wanted to express my appreciation for your tutorials. Your explanations are clear and easy to follow, which has greatly helped me. Keep up the fantastic work!
Cheers Andrei..I appreciate the kind words. Keep going 🦾
Underrated channel - Thanks Gary for the great content you provide.
Much appreciated
Kinda late to the party but for any junior developers watching this video DO NOT ever let the ValidationRuleInterface create its own validator as it makes it nearly impossible to inject any dependencies to the validator class and breaks the single responsibility principle. The attribute should at most define any required arguments for the validator (for string length validation the min and max length for example) and the error message. Let the validator or validator locator / chain pair the attribute with its correlating validator.
Overall great example of how to use attributes.
This very specific and visibly clear way of explaining attributes and how thing works in oop way. really appreciate this work. 👏 👏 👏 For garry
Thanks a lot...appreciate the kind words
You Sound like Simon Allardice from Pluralsight. This is exactly what I wanted to learn. Also I was following the PHP docs. Today have learned how to read them properly too. By clicking the returned type then reach for it's properties. Thanks Clarke
Glad it was helpful!
Wow, great tutorial. Thanks for sharing this amazing video
Thank you! Cheers!
Great video. Just wanted to point out though that 'use' does not actually import anything. It just tells PHP what fully qualified name to locate if that class is called (and now functions). Minor point, but ppl get this confused so much. 🙂
Another great video from you. Thanks for this video though i'm gonna watch it later. I'm very grateful from your php oop course video (i watched your 2 & 3 hour videos), now i understand the oop concept completely.
Excellent..keep going my friend 💪
Garry! Thank you! It is cool!
Thanks for your work, you are my guru in PHP
Happy to hear that!
Hey Gary!
I really liked this video! Is the continuation in the paid course?
Thanks for watching. Yes..the paid course includes the continuation. I'm adding new stuff to the full courses all the time.
At 32:52 - When INSTANCE_OF return value 2 does it mean the validation is true?
That was super neat!
Glad you think so!
Well done, mate! Impressive stuff you provide here!
Thanks a lot my awesome friend!
Very useful - Thank you
Glad to hear that!
Great & Great ❤❤ just I was thinking if it could be more straight forward by just having a validate method inside the Rule class itself instead of getValidator() and then call another class to do the validation. I mean the rule should define the validation logic itself and other wise it might not be actually a Required Rule !?
Thanks...no keep the logic separate. Define and validate the rule separately. Attributes shouldn't contain a lot of logic.
I have always wondered how the Attributes get validated in Symfony, and was a such black box to me. Thanks
Glad I could help!
Same, man!
Im having trouble finding your video where you creared the ReflectionClass. Could you please help me finding that video?
ReflectionClass is built into PHP. You don't need to create it.
@@GaryClarkeTechohhhhh thank you so much. And have you explained it in a video?
Not on RUclips I don't think but I teach it in the full OOP course
www.garyclarke.tech/p/learn-object-oriented-php
Wow great! Just what I wanted.
Enjoy!
Why you don't use mixed for type hints?
I don't see the point of mixed as a type hint tbh...seems quite meaningless
@@GaryClarkeTech in my opinion to do it, it's better because you can find all points with mixed declaration for later refactor and to pass PhpStan check.
Please how can we use Attributes to protect say, database credentials used to define a PDO connection. Exceptions thrown even within a try/catch, would reveal sensitive information!
Use the SensitiveParameter attribute:
www.php.net/manual/en/class.sensitiveparameter.php
@@GaryClarkeTech
Maybe, Gary, you can illustrate how. Because, I followed the link you gave us.
It seems that the Sensitive Parameter Attribute is to be used in the function/method definition NOT when Calling the function/method.
Should I extend the PDO Class and override the Constructor's handling of the Password, etc?
No..I wouldn't extend PDO, create your own Connection class which has PDO as a dependency. Then you can mark params on that class as sensitive and throw your own custom exceptions from that class if / when PDO exceptions are thrown and caught.
@@GaryClarkeTech
Thanks Gary.
I will give it a whirl.
Struggling mentally to figure out how this will work.
The way I figure stuff like this out is to start simple. So just create simple class with one method and a couple of parameters and add the SensitiveParameter attribute to it to get a feel for it. Then take what you know and apply it to your own code.
Here's a very simple Connection class which I created for the Test Driven PHP course:
github.com/GaryClarke/pest-tdd/blob/main/src/Database/Connection.php
wait, php people used to parse comments in production? are they crazy, or just trolls?
Does anyone else have trouble keeping track mentally of all the different ways to make and control classes? Seems almost impossible.
That's normal when you are starting out...everyone experiences the same thing. It gets easier, trust me!