Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Treehouse

Designing Interfaces in PHP Course

via Treehouse

Overview

Prepare for a new career with $100 off Coursera Plus
Gear up for jobs in high-demand fields: data analytics, digital marketing, and more.

An interface is a type of contract that assures that certain abilities are available on on a particular object class. We'll write and extend multiple interfaces, then implement them to design and match functionality. Interfaces do not store any implementation details themselves. To share implementation details between classes, we harness the power of inheritance. Abstract classes prevent a parent class from being directly instantiated, while at the same time defining methods that MUST be implemented in any extending children.

This course will combine interface contracts with class hierarchy to leverage the benefits of each concept. We'll explain the differences between interfaces and abstract classes, and give you the knowledge you need to build and implement both in your own projects.

What you'll learn

  • Writing an Interface
  • Implementing Interfaces
  • Extending Interfaces
  • Matching Interfaces
  • Abstract Classes

Syllabus

Introducing Interfaces

An interface is a type of contract that assures that the enforces certain abilities are available on on a particular object class. Interfaces have continued to gain popularity in PHP as the use of package management through composer has become the standard. By having standard interfaces, package maintainers can more easily build and maintain packages for common tasks such as Logging, caching and http messages.

Chevron 7 steps
  • What is an Interface

    3:18

  • Autoloading

    6:23

  • Autoloading, Classes and Interfaces

    6 questions

  • Writing an Interface

    3:57

  • Define an Interface

    2 objectives

  • Implementing an Interface

    8:07

  • Implement MySQL RepositoryInterface

    3 objectives

Using Interfaces

Often when working with interfaces, you will be using existing interfaces. Besides the interfaces that are built-in to PHP, most frameworks include their own interfaces. These interfaces work as a kind of guaranteed documentation for using individual components. By combining multiple interfaces we can build powerful components that can be easily understood by the rest of our application.

Chevron 9 steps
  • Code to Multiple Interfaces

    4:04

  • Implementing Interface Methods

    4:55

  • Implementing Interfaces

    1 objective

  • Extending an Interface

    5:43

  • Working with a Single Item

    5:50

  • Defining Interfaces

    2 objectives

  • Extending a Collection

    7:34

  • Testing for Interfaces

    4:01

  • Review Interfaces

    10 questions

Abstract Classes

We'll use an abstract class to implement some base properties and methods while still requiring additional functionality.

Chevron 9 steps
  • Abstract Class vs Interface

    3:43

  • Review Abstract Class

    5 questions

  • Abstract Methods and Classes

    3:48

  • Passing Abstract Methods

    3:36

  • Extending an Abstract Class

    4:31

  • Abstract Class

    4 objectives

  • Finishing Our Site

    5:57

  • Reviewing Use Cases

    3:29

  • Review Interfaces and Abstract Classes

    10 questions

Reviews

Start your review of Designing Interfaces in PHP Course

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.