1 00:00:00,000 --> 00:00:09,649 [MUSIC] 2 00:00:09,649 --> 00:00:12,598 Hello and welcome, I'm Alena, and I'm a developer. 3 00:00:12,598 --> 00:00:18,780 In this course, we're going to take on the task of building a REST API in PHP. 4 00:00:18,780 --> 00:00:22,024 Even if you've never used an API before, 5 00:00:22,024 --> 00:00:27,040 the good news is that all applications function in the same way. 6 00:00:27,040 --> 00:00:30,539 They take in a request and return a response. 7 00:00:30,539 --> 00:00:36,690 When building a web application, that response is returned in an HTML format. 8 00:00:36,690 --> 00:00:43,469 When building a REST API, that response is most often returned in a JSON format, 9 00:00:43,469 --> 00:00:48,467 although there are other formats available, such as XML. 10 00:00:48,467 --> 00:00:52,272 As for the request, when working with REST, 11 00:00:52,272 --> 00:00:56,882 the representational state transfer architecture, 12 00:00:56,882 --> 00:01:00,700 the big thing to remember is statelessness. 13 00:01:00,700 --> 00:01:07,548 The server does not store any state about the client session on the server side. 14 00:01:07,548 --> 00:01:12,682 Each request from the client to the server must contain all 15 00:01:12,682 --> 00:01:17,626 the information necessary to understand the request. 16 00:01:17,626 --> 00:01:22,510 This application state is not the same as the resource state. 17 00:01:22,510 --> 00:01:28,520 Application state is used to identify incoming client requests, 18 00:01:28,520 --> 00:01:35,294 their previous interaction details, and current context information. 19 00:01:35,294 --> 00:01:42,840 Resource state is the current state of a resource on a server at any point of time. 20 00:01:42,840 --> 00:01:48,389 And it has nothing to do with the interaction between the client and 21 00:01:48,389 --> 00:01:49,489 the server. 22 00:01:49,489 --> 00:01:55,728 It is what you get as a response from the server when requesting a resource. 23 00:01:55,728 --> 00:01:58,464 Before continuing this course, 24 00:01:58,464 --> 00:02:04,240 you should be familiar with the basics of a REST API and using Postman. 25 00:02:04,240 --> 00:02:08,978 Additionally, we'll be using the slim micro framework to 26 00:02:08,978 --> 00:02:10,975 help us manage our code. 27 00:02:10,975 --> 00:02:15,532 If you aren't sure about any of the items I just mentioned, make sure you 28 00:02:15,532 --> 00:02:20,102 check the notes associated with this video for a list of prerequisites. 29 00:02:20,102 --> 00:02:26,283 As always, there are video controls to slow me way down and 30 00:02:26,283 --> 00:02:30,330 to speed me up if I start to get boring. 31 00:02:30,330 --> 00:02:34,477 The ability to build a REST API is becoming more and 32 00:02:34,477 --> 00:02:40,522 more a required skill that you absolutely need to have in your tool belt. 33 00:02:40,522 --> 00:02:43,623 Client-side frameworks are taking off, and 34 00:02:43,623 --> 00:02:48,010 they're all expecting a back end server to do the heavy lifting. 35 00:02:48,010 --> 00:02:51,839 They almost all follow REST out of the box. 36 00:02:51,839 --> 00:02:55,071 Mobile applications have exploded, and 37 00:02:55,071 --> 00:02:59,882 just about every company has or wants a mobile app these days. 38 00:02:59,882 --> 00:03:04,236 These apps need to talk with existing infrastructure and 39 00:03:04,236 --> 00:03:06,600 they usually do it using REST. 40 00:03:06,600 --> 00:03:10,952 So what better way to get started exploring building a REST API 41 00:03:10,952 --> 00:03:15,230 than using a very straightforward approach to the problem? 42 00:03:15,230 --> 00:03:19,878 We're going to build a REST API that allows you to submit reviews of 43 00:03:19,878 --> 00:03:21,126 online courses. 44 00:03:21,126 --> 00:03:24,456 Obviously, when reviewing Treehouse courses, 45 00:03:24,456 --> 00:03:27,790 these are going to be a five out of a possible five. 46 00:03:27,790 --> 00:03:31,400 But our API is made to accept courses from anywhere. 47 00:03:31,400 --> 00:03:36,996 The client of the API can request a list of courses that have reviews, 48 00:03:36,996 --> 00:03:40,389 as well as submit a new course and review. 49 00:03:40,389 --> 00:03:44,314 This aggregating of information is a common use 50 00:03:44,314 --> 00:03:47,560 case of a software as a service or SaaS. 51 00:03:47,560 --> 00:03:49,895 Are you ready to get started?