© Paul Redmond 2016

Paul Redmond, Lumen Programming Guide, 10.1007/978-1-4842-2187-7_4

4. Starting the Books API

Paul Redmond

(1)Phoenix, Arizona, USA

In this chapter, we will focus on writing our first API resource: /books. We will take this in small chunks and test it as we go. At the end of the next few chapters we will have a fully-tested /books resource doing basic CRUD operations. The /books resource will look like this:

Basic REST /books Resource

GET /books Get all the booksPOST /books Create a new bookGET /books/{id} Get a bookPUT /books/{id} Update a bookDELETE /books/{id} Delete a book

Creating the First Endpoint

The first order of business to create a BooksControllerTest class and write your first failing test. You will then write the minimum ...

Get Lumen Programming Guide: Writing PHP Microservices, REST and Web Service APIs now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.