1 00:00:00,000 --> 00:00:04,899 [MUSIC] 2 00:00:04,899 --> 00:00:09,568 If you have a drivers license, you've probably driven more than one car. 3 00:00:09,568 --> 00:00:13,490 You don't have to relearn to drive every time you drive a new car, 4 00:00:13,490 --> 00:00:16,068 because each car uses the same interface. 5 00:00:16,068 --> 00:00:20,528 There's the way to accelerate break, turn and shift gears. 6 00:00:20,528 --> 00:00:22,850 Each car may handle a little differently, and 7 00:00:22,850 --> 00:00:27,900 you'll feel more comfortable with certain vehicles, and it's the same way with code. 8 00:00:27,900 --> 00:00:31,990 If you're familiar with one logging system and switch to another logging system with 9 00:00:31,990 --> 00:00:36,650 the same interface, the transition should be fairly easy. 10 00:00:36,650 --> 00:00:41,528 Although you may feel more comfortable working with the system that you find most 11 00:00:41,528 --> 00:00:42,252 familiar. 12 00:00:42,252 --> 00:00:47,649 Hi, I'm Alina and in this course, we're going to look at an important concept, 13 00:00:47,649 --> 00:00:50,960 an object-oriented design called interfaces. 14 00:00:50,960 --> 00:00:53,440 An interface is a type of contract 15 00:00:53,440 --> 00:00:57,720 that assures certain abilities are available on a particular object class. 16 00:00:58,840 --> 00:01:02,446 Interfaces have continued to gain popularity in PHP. 17 00:01:02,446 --> 00:01:07,380 As the use of package management through composer has become the standard. 18 00:01:07,380 --> 00:01:13,106 By having standard interfaces, package maintainers can more easily build and 19 00:01:13,106 --> 00:01:19,354 maintain packages for common tasks, such as logging, caching, and HTTP messages. 20 00:01:19,354 --> 00:01:23,097 The PHP Framework Interop Group, or PHP FIG for short, 21 00:01:23,097 --> 00:01:27,950 has also been a leader in standardizing common interfaces. 22 00:01:27,950 --> 00:01:32,799 Check out the notes associated with this video to learn more about composer, 23 00:01:32,799 --> 00:01:34,452 standards, and the fig. 24 00:01:34,452 --> 00:01:37,760 So how do interfaces fit with class hierarchy? 25 00:01:37,760 --> 00:01:38,670 Lets talk tomatoes. 26 00:01:39,680 --> 00:01:43,330 Botanically speaking, a fruit is a seed baring structure 27 00:01:43,330 --> 00:01:46,750 that develops from the ovary of a flowering plant. 28 00:01:46,750 --> 00:01:53,350 Where as vegetables are all other plant parts such as, roots, leaves, and stems. 29 00:01:53,350 --> 00:01:55,810 By those standards, tomatoes are a fruit. 30 00:01:56,980 --> 00:02:00,660 In culinary terms, however, it's a different matter. 31 00:02:00,660 --> 00:02:02,410 When cooking, many foods, 32 00:02:02,410 --> 00:02:06,950 such as tomatoes, which botanically speaking are fruits, 33 00:02:06,950 --> 00:02:11,670 are typically considered vegetables because they are savory rather than sweet. 34 00:02:12,940 --> 00:02:18,250 If a tomato were a PHP class, it would inherit it's properties from the fruit 35 00:02:18,250 --> 00:02:23,900 class, but it implements the savoryFlavor interface of a vegetable. 36 00:02:23,900 --> 00:02:28,780 Allowing us to use these fruits in recipes that require a savory flavor. 37 00:02:29,980 --> 00:02:32,810 In this course, we'll explore interfaces and 38 00:02:32,810 --> 00:02:37,773 abstract classes by building a website that displays different types of content. 39 00:02:40,531 --> 00:02:45,342 Using pages and blog posts, we'll explore the use of interfaces through 40 00:02:45,342 --> 00:02:48,699 the creation of these different types of content. 41 00:02:48,699 --> 00:02:52,430 We'll also pull that content from different data sources. 42 00:02:53,620 --> 00:02:58,680 The project will combine interface contracts with class hierarchy by creating 43 00:02:58,680 --> 00:03:03,540 an abstract class and demonstrate how abstract classes can be used 44 00:03:03,540 --> 00:03:08,030 to enforce the contract of an interface while building a class hierarchy. 45 00:03:09,030 --> 00:03:12,050 This course will explain the differences between interfaces and 46 00:03:12,050 --> 00:03:16,010 abstract classes, and give you the knowledge you need to build, and 47 00:03:16,010 --> 00:03:17,950 implement both in your own projects.