Error handling

When we throw an exception because something happened during the execution of our application, we should give more information to our users or consumers about what happened. This is possible by adding describable standard codes, also known as status codes. Using these standard codes in your responses will help you (and your colleagues) to know quickly if something is going wrong in your application. Check the following list to know what are the correct and most common HTTP status codes to use them in your API.

Client request successful

If your application needs to inform the API client that the request was successful, you would usually reply with one of the following HTTP status codes:

  • 200 - OK: The request was done successfully
  • 201 ...

Get PHP Microservices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.