PHP OOP Tutorial | What is a PHP interface

A PHP tutorial demonstrating how to use interfaces to make your code cleaner, reusable and adhere to certain solid principles. This PHP tutorial is aimed at PHP developers at a beginner level who are learning object orientated programming (OOP)




Manning programming books and courses:

PHP Books:

PHP Hosting from Cloudways:

======== MY PROGRAMMING COURSES ========

Docker in Motion:
Skillshare courses:
Udemy courses:

======== WEB HOSTING DEALS ========

Cloudways: = 20% off first 6 months
Digital Ocean: = $10 off


Join the Newsletter:

======== FOLLOW ME ========


======== MY TALKS ========

How to put your Docker image on a diet:

======== SUPPORT THE CHANNEL ========

Become a Patron:
Help translate the videos:

======== VIDEO SETUP ========

Nikon D5300 Camera:
Logitech HD Pro Webcam C920
CRAPHY Photography Studio Lights:
Rode Procaster Microphone:
Rode VideoMic Pro:
Zoom H4NPro:


Raphael A. Alves says:

In the case of shapes, couldnt you just use an abstract inheritance with abstract functions instead of interface?

Rich Williams says:

you know you use an interface to be able to swap between different classes… wouldnt a drop down menu on the users side do the same? or is this what the interface allows you to do on the users side?

Rich Williams says:

where do these functions go in your code? you use ‘includes’ to call them?

Sean Kelly says:

Really really great stuff. Do you do more of this?

Wyckham Seelig says:

Peter, Is the code in this tutorial available on github? Searched for it and didn’t find anything?

Carl Ortiz says:

Why don’t you just put the fraud checking method inside pay method?

Lightspeed says:

It helped me now to understand the reason why to use interfaces. Thank you! :)

Contabilidade 00 Império Contábil says:

Ok, this makes me look stupid but the truth is that I am a PHP developer for over a decade and never understood the purpose of interfaces. Yes, I have read a dozen of tutorials and stuff but yeah, it never broke into my skull.

Your payment example just did the click in my brain. It further consolidated when you said at the end that there is no need for a bunch of if statements.

Thank you mate!!!!

webhtg says:

Great explanation Sir . I watched some videos about SOLID principle and if I am not wrong , the example shown in this video is Interface Segregation . Waiting for full in-depth tutorials with examples about SOLID in PHP . thanks again for this video .

Rich Williams says:

i thought duplication was a bad there a better way to put the three shapes in the same class or call them with the same attributes somehow? i like the format of code and you on same screen..alot easier to concentrate. thx

Peter Fisher says:

Today’s tutorial covers PHP interfaces! Interfaces are the very important for object oriented programming. Let me know what other OOP subjects you wish me to cover in future videos

busyrand says:

RUN PHP!!! Awesome Mug!

Thomas Varghese says:

Thanks for the great tutorial. There is a confusion I am having about the object you declared for the payment gateway example. Since you created an object only for mintfee and passed it how will other 2 class methods will be code. I tried to run the code you have given and only the mintfee class methods are called. Can you explain that and clear the doubt?

Hello World says:

Stop looking at the keyboard, and u will be making less mistakes after a while.

Rahifi Robinson says:

Hi, do you know a few emerging trends respect to php interfaces?

May See says:

Thanks for your explanation! Only interface tutorial I have understood 😀

Tom Scott says:

This is a great explanation. Just one thing. In the first 10 minutes with the shape example, you added ‘shape interface’ as a parameter in the addShape method. What does this do as I believe this would still work with only $shape as the argument?

Chrismarcel James says:

I’m just seeing this video and I appreciate your simplified explanation, I just read a source on Dependency Injection and how ir eliminates tight coupling. This looks quite similar to what was implemented in the source I read. Could your example be likened to a somewhat implementation of Dependency Injection.

Kajetan Dziebaj says:

Thanks, brah. I understand interfaces now.

Write a comment


Human Verification: In order to verify that you are a human and not a spam bot, please enter the answer into the following box below based on the instructions contained in the graphic.

Do you like our videos?
Do you want to see more like that?

Please click below to support us on Facebook!

Send this to a friend

▷ Other ReviewsVehicles Show Cars Motorbikes Scooters Rims & Tires Luxury BoatsFashion Sunglasses Luxury Watches Luxury Purses Jeans Wear High Heels Perfumes Jewellery Cosmetics Shaving Helpers Fashion HatsFooding Chef Club Fooding Helpers Coktails & LiquorsSports Sport Shoes Fitness & Detox Golf Gear Racquets Diving Equipment Ski Gear Snowboards Surf Boards Rollers & SkatesEntertainment DIY Guides Zik Instruments Published Books Music Albums Cine Movies Trading Helpers Make Money Fishing Equipment Paintball Supplies Trading Card Games Telescopes Knives VapesHigh Tech Flat Screens Tech Devices Camera Lenses Printers USB Devices PC Hardware Network Gear Cloud Servers Software Helpers Programmer Helpers Mobile Apps Hearing AidsHome Home Furniture Home Appliances Beddings Floor Layings Barbecues Aquarium Gear Safe Boxes Office Supplies Security Locks Cleaning ProductsKids Baby Strollers Child Car Seats Remote ControlledTravel Luggages & Bags Airlines Seats Hotel Rooms Fun Trips Cruise Ships Mexico Tours