When to use Traits, Interfaces, and Abstract Classes in PHP

preview_player
Показать описание
If you've been working in PHP for at least a little while, chances are you've come across a Trait, Interface, or Abstract Class. What are they? How can I use them effectively?

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

Рекомендации по теме
Комментарии
Автор

The clearest explanation of these that I have ever seen.
A lower-than-dummy will grasp these so easily.

Thanks Buddy. Appreciated

NedumEze
Автор

Always a good idea to refresh the basics. Thank you 👍

Tuto
Автор

This is by far my favourite channel for learning SOLID and design patterns. I've struggled with this subject for so long.

this.channel
Автор

Really appreciate the real-life example of play/concert/movie to illustrate when best to use trait and interface.

Dekedence
Автор

Straight to the point.
I'll be watching this video a lot in the coming months, thank you.

siphosethudlomo
Автор

Man, this is so clearly explained. What a great refresher. Thanks Andrew!

DallinHitchcock
Автор

Such a clear explanation! Thank you, Andrew!

VitorJustin
Автор

Such a helpful tutorial, it boosted my basics. Thank you ❤

KHALEDMORSHED
Автор

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!!

bsky
Автор

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.

Staeufer
Автор

You just got yourself a new subscriber!!! Thanks Andrew.

hammedmujeeb
Автор

I knew Interfaces, I knew Traits, I literally have never thought of Abstract classes as a combination of those two things - thanks!!

andrewmusholt
Автор

thank you, explanation is easy to understand and follow

fayetan
Автор

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.

rcnhsuailsnyfiue
Автор

you explain everything very well, i could make very useful notes out of your video. thank you for the demonstration!

daria.butterflycookies
Автор

Great example and as usual a very clear explanation. Thanks, Andrew!
I have followed your vids for a while, but I just noticed I never subscribed. I did that today ;)

joebashour
Автор

Hi i like this video very nicely explain ❤❤ thanks 👍

SparYT
Автор

what ide and extension do you use to see that beautiful error box/message when hovering? thanks

kirayamato
Автор

how managed to execute the object without composer or namespace ?

when I try to execute, php index.php, an error message appears. Fatal error: Uncaught Error: Class "movie" not found in C:\laragon\www\index.php:17

pwcodigo