No video

PHP Attributes 50 Minute Tutorial

  Рет қаралды 8,898

Gary Clarke

Gary Clarke

Күн бұрын

Dive into PHP attributes as we use them to implement validation rules in a DTO, showcasing a practical and efficient coding approach.
Check out THE FULL COURSE and get the code examples here:
www.garyclarke.tech/p/learn-o...
🆓 Join garyclarke.tech for course DISCOUNTS and a FREE Docker + PHP course (worth $49)
www.garyclarke.tech
👇 Follow me on Social Media:
Twitter: / garyclarketech
Linkedin: / garyclarketech
💕Show support:
www.paypal.com/donate/?hosted...
0:00 Introduction
3:50 Data Transfer Objects
10:05 Readonly Properties and Classes
14:18 Creating Custom Attributes
15:57 Applying Attributes
17:40 Validation Mechanism
26:08 Attributes and Interfaces
34:13 Instantiating Attributes
40:18 Custom Validator Classes
45:40 Get the full course

Пікірлер: 59
@salimibrohimi9813
@salimibrohimi9813 10 ай бұрын
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!
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Thanks a lot..appreciate the kind words...hope I didn't make you late for anything!
@CodefyPHP
@CodefyPHP 10 ай бұрын
Thanks, Gary for taking the time to explain attributes. This tutorial is simple to follow for all levels of PHP developers.
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
You're very welcome!
@davidmutua6971
@davidmutua6971 3 ай бұрын
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
@GaryClarkeTech
@GaryClarkeTech 3 ай бұрын
Glad it was helpful!
@theman7050
@theman7050 8 ай бұрын
You are a legend for any Wordpress/PHP developer. Thank you so much :D
@GaryClarkeTech
@GaryClarkeTech 8 ай бұрын
You're welcome...thanks for watching!
@michaelhitzler8085
@michaelhitzler8085 9 ай бұрын
One of the best PHP tutorials I have seen so far. Very well explained!
@GaryClarkeTech
@GaryClarkeTech 9 ай бұрын
Thanks for watching...I appreciate the kind words!
@mohammadabughrara6319
@mohammadabughrara6319 5 ай бұрын
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.
@GaryClarkeTech
@GaryClarkeTech 5 ай бұрын
You're welcome. Glad I could help!
@OmarAli-gm5lx
@OmarAli-gm5lx 4 ай бұрын
Full explanation is in the PHP docs also..
@andreiramboiu5184
@andreiramboiu5184 7 ай бұрын
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!
@GaryClarkeTech
@GaryClarkeTech 7 ай бұрын
Cheers Andrei..I appreciate the kind words. Keep going 🦾
@AKcomedyshorts1507
@AKcomedyshorts1507 4 ай бұрын
This very specific and visibly clear way of explaining attributes and how thing works in oop way. really appreciate this work. 👏 👏 👏 For garry
@GaryClarkeTech
@GaryClarkeTech 4 ай бұрын
Thanks a lot...appreciate the kind words
@tonyto2009
@tonyto2009 10 ай бұрын
Underrated channel - Thanks Gary for the great content you provide.
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Much appreciated
@user-ys3uu5un6l
@user-ys3uu5un6l 9 ай бұрын
Garry! Thank you! It is cool!
@hanzai_keisu
@hanzai_keisu 10 ай бұрын
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.
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Excellent..keep going my friend 💪
@rezalaal
@rezalaal 10 ай бұрын
Very useful - Thank you
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Glad to hear that!
@ukasz8561
@ukasz8561 10 ай бұрын
Thanks for your work, you are my guru in PHP
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Happy to hear that!
@DaviMartins99
@DaviMartins99 10 ай бұрын
That was super neat!
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Glad you think so!
@millennia
@millennia 10 ай бұрын
Wow great! Just what I wanted.
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Enjoy!
@TioJobs
@TioJobs 9 ай бұрын
Hey Gary! I really liked this video! Is the continuation in the paid course?
@GaryClarkeTech
@GaryClarkeTech 9 ай бұрын
Thanks for watching. Yes..the paid course includes the continuation. I'm adding new stuff to the full courses all the time.
@ashrafbeshtawi3556
@ashrafbeshtawi3556 10 ай бұрын
I have always wondered how the Attributes get validated in Symfony, and was a such black box to me. Thanks
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Glad I could help!
@DaviMartins99
@DaviMartins99 10 ай бұрын
Same, man!
@a.karamat2168
@a.karamat2168 6 ай бұрын
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
@GaryClarkeTech 6 ай бұрын
Thanks...no keep the logic separate. Define and validate the rule separately. Attributes shouldn't contain a lot of logic.
@GuidoAlvarez-fm9hg
@GuidoAlvarez-fm9hg Ай бұрын
At 32:52 - When INSTANCE_OF return value 2 does it mean the validation is true?
@theman7050
@theman7050 7 ай бұрын
Im having trouble finding your video where you creared the ReflectionClass. Could you please help me finding that video?
@GaryClarkeTech
@GaryClarkeTech 7 ай бұрын
ReflectionClass is built into PHP. You don't need to create it.
@theman7050
@theman7050 7 ай бұрын
​​@@GaryClarkeTechohhhhh thank you so much. And have you explained it in a video?
@GaryClarkeTech
@GaryClarkeTech 7 ай бұрын
Not on KZbin I don't think but I teach it in the full OOP course www.garyclarke.tech/p/learn-object-oriented-php
@moofymoo
@moofymoo 2 ай бұрын
wait, php people used to parse comments in production? are they crazy, or just trolls?
@nerjuz
@nerjuz 10 ай бұрын
Why you don't use mixed for type hints?
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
I don't see the point of mixed as a type hint tbh...seems quite meaningless
@nerjuz
@nerjuz 10 ай бұрын
@@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.
@Dev-sf3pz
@Dev-sf3pz 10 ай бұрын
Does anyone else have trouble keeping track mentally of all the different ways to make and control classes? Seems almost impossible.
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
That's normal when you are starting out...everyone experiences the same thing. It gets easier, trust me!
@NedumEze
@NedumEze 8 ай бұрын
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
@GaryClarkeTech 8 ай бұрын
Use the SensitiveParameter attribute: www.php.net/manual/en/class.sensitiveparameter.php
@NedumEze
@NedumEze 8 ай бұрын
@@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?
@GaryClarkeTech
@GaryClarkeTech 8 ай бұрын
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.
@NedumEze
@NedumEze 8 ай бұрын
@@GaryClarkeTech Thanks Gary. I will give it a whirl. Struggling mentally to figure out how this will work.
@GaryClarkeTech
@GaryClarkeTech 8 ай бұрын
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
@LaravelJutsu
@LaravelJutsu 10 ай бұрын
Well done, mate! Impressive stuff you provide here!
@GaryClarkeTech
@GaryClarkeTech 10 ай бұрын
Thanks a lot my awesome friend!
PHP Enums tutorial
22:58
Gary Clarke
Рет қаралды 3,7 М.
When to use Traits, Interfaces, and Abstract Classes in PHP
15:08
Andrew Schmelyun
Рет қаралды 17 М.
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 59 МЛН
Inside Out 2: Who is the strongest? Joy vs Envy vs Anger #shorts #animation
00:22
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 24 МЛН
НРАВИТСЯ ЭТОТ ФОРМАТ??
00:37
МЯТНАЯ ФАНТА
Рет қаралды 8 МЛН
5 Rules For DTOs
17:56
Ardalis
Рет қаралды 39 М.
5 Design Patterns That Are ACTUALLY Used By Developers
9:27
Alex Hyett
Рет қаралды 233 М.
Refactoring to action pipelines in Laravel
1:25:03
Michael Dyrynda
Рет қаралды 9 М.
Is PHP the Secret King of Code?
6:42
Stefan Mischook
Рет қаралды 54 М.
Brutally honest advice for new .NET Web Developers
7:19
Ed Andersen
Рет қаралды 115 М.
Svelte 5's Secret Weapon: Classes + Context
18:14
Huntabyte
Рет қаралды 14 М.
"The Life & Death of htmx" by Alexander Petros at Big Sky Dev Con 2024
23:01
Montana Programmers
Рет қаралды 42 М.
What's New in PHP 8.3 - Derick Rethans
59:11
PHP UK Conference
Рет қаралды 5 М.
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 59 МЛН