O'Reilly logo

Lumen Programming Guide: Writing PHP Microservices, REST and Web Service APIs by Paul Redmond

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

© Paul Redmond 2016

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

6. Responding to Errors

Paul Redmond

(1)Phoenix, Arizona, USA

During your work on the Book API in Chapter 5 it became evident that you need to start using a separate test database. You also don’t have very good error responses for API consumers yet. Responding to a client with an HTML error that expects JSON is not going to cut it anymore. When an API consumer interacts with your API, you want to respond with the correct Content-Type header. For now, you will assume all of your consumers want JSON, and in my experience, JSON is typically what consumers want.

Test Database

The main focus of this chapter will be error responses, but before you work on error responses ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required