Handle the API problems with ease using Laravel Faulty
kamranahmedse released a package that we can use to automatically turn thrown exceptions (HTTP/non-HTTP) to the JSON response.
Faulty provides a straightforward implementation of IETF Problem Specification and turns your exceptions to be returned in the below format with the content type of application/problem+json
{ "status": 403, "type": "http://example.com/problems/out-of-credit", "title": "You do not have enough credit.", "detail": "Your current balance is 30, but that costs 50.", "instance": "http://example.net/account/12345/logs?id=233" }
Link:
This post is submitted by our members. Submit a new post.
Tags: Tutorials Packages Laravel 5.1 Laravel 5 Laravel 5.2 Laravel 5.3 Intermediate