What is an Interface3:18 with Alena Holligan
An Interface is a contract that guarantee specific functionality is defined for an object. By using interfaces, one developer can write the implementation details, while another developer can be assured of how they will interact with that object. We'll look at what this means and how interfaces fit with class hierarchy.
Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
Learn more about the PHP Framework Interop Group (PHP FIG)
A group of established PHP projects whose goal is to talk about commonalities between our projects and find ways we can work better together.
[MUSIC] 0:00 If you have a drivers license, you've probably driven more than one car. 0:04 You don't have to relearn to drive every time you drive a new car, 0:09 because each car uses the same interface. 0:13 There's the way to accelerate break, turn and shift gears. 0:16 Each car may handle a little differently, and 0:20 you'll feel more comfortable with certain vehicles, and it's the same way with code. 0:22 If you're familiar with one logging system and switch to another logging system with 0:27 the same interface, the transition should be fairly easy. 0:31 Although you may feel more comfortable working with the system that you find most 0:36 familiar. 0:41 Hi, I'm Alina and in this course, we're going to look at an important concept, 0:42 an object-oriented design called interfaces. 0:47 An interface is a type of contract 0:50 that assures certain abilities are available on a particular object class. 0:53 Interfaces have continued to gain popularity in PHP. 0:58 As the use of package management through composer has become the standard. 1:02 By having standard interfaces, package maintainers can more easily build and 1:07 maintain packages for common tasks, such as logging, caching, and HTTP messages. 1:13 The PHP Framework Interop Group, or PHP FIG for short, 1:19 has also been a leader in standardizing common interfaces. 1:23 Check out the notes associated with this video to learn more about composer, 1:27 standards, and the fig. 1:32 So how do interfaces fit with class hierarchy? 1:34 Lets talk tomatoes. 1:37 Botanically speaking, a fruit is a seed baring structure 1:39 that develops from the ovary of a flowering plant. 1:43 Where as vegetables are all other plant parts such as, roots, leaves, and stems. 1:46 By those standards, tomatoes are a fruit. 1:53 In culinary terms, however, it's a different matter. 1:56 When cooking, many foods, 2:00 such as tomatoes, which botanically speaking are fruits, 2:02 are typically considered vegetables because they are savory rather than sweet. 2:06 If a tomato were a PHP class, it would inherit it's properties from the fruit 2:12 class, but it implements the savoryFlavor interface of a vegetable. 2:18 Allowing us to use these fruits in recipes that require a savory flavor. 2:23 In this course, we'll explore interfaces and 2:29 abstract classes by building a website that displays different types of content. 2:32 Using pages and blog posts, we'll explore the use of interfaces through 2:40 the creation of these different types of content. 2:45 We'll also pull that content from different data sources. 2:48 The project will combine interface contracts with class hierarchy by creating 2:53 an abstract class and demonstrate how abstract classes can be used 2:58 to enforce the contract of an interface while building a class hierarchy. 3:03 This course will explain the differences between interfaces and 3:09 abstract classes, and give you the knowledge you need to build, and 3:12 implement both in your own projects. 3:16
You need to sign up for Treehouse in order to download course files.Sign up