In this video, Keith Casey walks through the first stage of our project: getting simple data out of the database, no authorization, simple error handling, simple logging.
- [Instructor] Hello, and welcome to routing and middleware basics. In this section, we're going to look at our first project requirements, and start sketching out the API that will let us accomplish something useful. Notice that I don't say let us create, read, update, and delete database objects. While those things might be useful, throughout this course, we're not just building crud over HTTP, but something useful and valuable to our end-users, or customers. It's a subtle distinction that will be more important as we get deeper into building our API.
Let's talk about the current phase of our project in more detail. Earlier, I said we were taking a simple Twitter-like service, called Chatter, and augmenting it with an API. For this phase, we'll start with the thinnest, simplest layer that will do something useful. In this case, we'll set up a framework, and configure a single route to retrieve messages. Each message will have a body, a sender, which is the user who created it, and a datetime. We're not even going to worry about time zones at this point. We're just going to expose the raw data.
Further, when not going to worry about authentication, content negotiation, error handling, or anything else along those lines. Those things will come later. It's also worth noting that, at this first step in our API, the API itself may feel ugly, or inefficient. It hurts a little at the moment, but I promise we'll take care of that. Our only goal at this stage is to learn about the first of the few core principles that we need, requests and responses.
This course begins with a simple application specification and builds it one step at a time. Each chapter includes a key concept, with examples from other public APIs, and then shows how to build it yourself with Silex. Learn about URL routing, validating input, and generating response codes and hypermedia payloads. Like any project, the first implementation may be a little messy, but don't worry. The last chapter covers refactoring and what it takes to scale and support the API going forward.
- Understanding the project goals
- Adding authentication with Silex
- Using cross-framework and authentication middleware
- Creating a read-write API in Silex
- Uploading files via an API
- Adding file security
- Creating payloads and response codes in Silex
- Scaling your API