Repository navigation
Releases
Releases · Pharaonic/laravel-api-response
v6.0.0
Added
Response:success(),created(),accepted(),noContent(),error(),unauthorized(),forbidden(),notFound()andvalidationError(), withdata(),message(),status(),code(),errors(),meta(),notify(),profile(),withSEO(),withRequestId(),withoutRequestId(),withQueryString(),withoutQueryString(),withoutPagination(),header(),withHeaders(),when(),unless(),transform()andresponse(). It isResponsableand macroable. An error refusesdata()and a success refuseserrors().- Length-aware and simple paginators, resource collections over them, and
Contracts\PaginationAdapterfor other paginators, sent as their items plusmeta.pagination. Cursor paginators are supported from Laravel 8.41. - Profiles (
Profiles\Profile), chosen by the response, theUseResponseProfilemiddleware, theAcceptmedia type, or the default, and configurable envelope field names. ExceptionRendererandContracts\ExceptionMapperfor opt-in JSON rendering of exceptions on API requests. HTTP exceptions get a fixed code per status (RFC 9110 names,HTTP_<status>otherwise), or the code of theirerrorCode()method in upper case and the message of theirlocalizedMessage()method, as the exceptions ofpharaonic/laravel-api-versioningandpharaonic/laravel-api-idempotencyhave; those are rendered in the envelope even with arender()method, and for every request. Configured mappers are asked before an exception's ownrender(). Withapp.debugon, aModelNotFoundExceptionadds the model class and the missing keys tometa.debug.- Translated messages in the
api-responsenamespace, English and Arabic, published with theapi-response-translationstag. The status helpers' defaults and every built-in exception message follow the application locale; codes do not. - The
AssignRequestIdmiddleware, with the ID in a header, the body and log records. - Optional
pharaonic/laravel-seo(6.1 or later) tags throughwithSEO().
Compatibility
- Laravel 6 on PHP 8.0.