Getting Started with Our API3:49 with Alena Holligan
In this course, we’re going to take on the task of building a REST API in PHP. Even if you've never used an API before, the good news is that all applications function in the same way. They take in a request and return a response. When building a web application, that response is returned in an HTML format. When building a REST API, that response is most often returned in a JSON format, although there are other formats available, such as XML.
[MUSIC] 0:00 Hello and welcome, I'm Alena, and I'm a developer. 0:09 In this course, we're going to take on the task of building a REST API in PHP. 0:12 Even if you've never used an API before, 0:18 the good news is that all applications function in the same way. 0:22 They take in a request and return a response. 0:27 When building a web application, that response is returned in an HTML format. 0:30 When building a REST API, that response is most often returned in a JSON format, 0:36 although there are other formats available, such as XML. 0:43 As for the request, when working with REST, 0:48 the representational state transfer architecture, 0:52 the big thing to remember is statelessness. 0:56 The server does not store any state about the client session on the server side. 1:00 Each request from the client to the server must contain all 1:07 the information necessary to understand the request. 1:12 This application state is not the same as the resource state. 1:17 Application state is used to identify incoming client requests, 1:22 their previous interaction details, and current context information. 1:28 Resource state is the current state of a resource on a server at any point of time. 1:35 And it has nothing to do with the interaction between the client and 1:42 the server. 1:48 It is what you get as a response from the server when requesting a resource. 1:49 Before continuing this course, 1:55 you should be familiar with the basics of a REST API and using Postman. 1:58 Additionally, we'll be using the slim micro framework to 2:04 help us manage our code. 2:08 If you aren't sure about any of the items I just mentioned, make sure you 2:10 check the notes associated with this video for a list of prerequisites. 2:15 As always, there are video controls to slow me way down and 2:20 to speed me up if I start to get boring. 2:26 The ability to build a REST API is becoming more and 2:30 more a required skill that you absolutely need to have in your tool belt. 2:34 Client-side frameworks are taking off, and 2:40 they're all expecting a back end server to do the heavy lifting. 2:43 They almost all follow REST out of the box. 2:48 Mobile applications have exploded, and 2:51 just about every company has or wants a mobile app these days. 2:55 These apps need to talk with existing infrastructure and 2:59 they usually do it using REST. 3:04 So what better way to get started exploring building a REST API 3:06 than using a very straightforward approach to the problem? 3:10 We're going to build a REST API that allows you to submit reviews of 3:15 online courses. 3:19 Obviously, when reviewing Treehouse courses, 3:21 these are going to be a five out of a possible five. 3:24 But our API is made to accept courses from anywhere. 3:27 The client of the API can request a list of courses that have reviews, 3:31 as well as submit a new course and review. 3:36 This aggregating of information is a common use 3:40 case of a software as a service or SaaS. 3:44 Are you ready to get started? 3:47
You need to sign up for Treehouse in order to download course files.Sign up