When to use Traits, Interfaces, and Abstract Classes in PHP
15,709
2023-08-25に共有
Let's dive in and discover a couple of use cases for each of them, and I'll explain some of their differences (and similarities).
- 0:00 TL;DR
- 0:47 Intro
- 1:25 Traits
- 5:48 Interfaces
- 10:27 Abstract Classes
- 14:49 All Done
Send me new video ideas and vote on what's coming next: suggest.gg/aschmelyun
Follow me on Twitter! twitter.com/aschmelyun
Join my newsletter, where I send out new information about twice a month in the PHP, JavaScript, and Docker realms: aschmelyun.substack.com/
コメント (21)
-
This is by far my favourite channel for learning SOLID and design patterns. I've struggled with this subject for so long.
-
Always a good idea to refresh the basics. Thank you 👍
-
Man, this is so clearly explained. What a great refresher. Thanks Andrew!
-
Really appreciate the real-life example of play/concert/movie to illustrate when best to use trait and interface.
-
Straight to the point. I'll be watching this video a lot in the coming months, thank you.
-
Awesome explanation! I found your channel through our mutual buddy Salazar, and you explained these concepts a bit better than Jeffrey Way did when I first saw his PHP OOP series on Laracasts years ago. Keep em coming!!
-
Such a clear explanation! Thank you, Andrew!
-
Thanks for the explanation and the examples. After reading the docs, I wasn't quite sure why all 3 exist and when to use them. Now with all 3 in context together, it makes perfect sense.
-
thank you, explanation is easy to understand and follow
-
Such a helpful tutorial, it boosted my basics. Thank you ❤
-
You just got yourself a new subscriber!!! Thanks Andrew.
-
Wonderful explanation! Thank you ❤
-
I knew Interfaces, I knew Traits, I literally have never thought of Abstract classes as a combination of those two things - thanks!!
-
Great Explanation!!!
-
Traits are one of my favorite PHP features, they’re so helpful. I have a tenanted B2B application which runs in both the “user context” and the “business context” interchangeably. With a shared trait on both my User and Business models, I can access and interact with the current user (or their business) on either model, or even on any of their Eloquent relations too. Makes for great DX in a complex application like this one.
-
Great refresher, thanks!!
-
very good explanation, thanks
-
Oh merci d’avoir abordé ce sujet
-
you explain everything very well, i could make very useful notes out of your video. thank you for the demonstration!
-
Thank you Andrew.