floor9design / laravel-json-api-exceptions
Add easy to use extensible JSON:API errors in the Laravel framework
Package info
github.com/floor9design-ltd/laravel-json-api-exceptions
pkg:composer/floor9design/laravel-json-api-exceptions
Requires
- php: ^8.2
- ext-json: *
- floor9design/json-api-formatter: ^2.0
- laravel/framework: ^12.0 || ^13.0
- ramsey/uuid: ^4.7
- symfony/http-kernel: ^7.2 || ^8.0
Requires (Dev)
- floor9design/testing-tools: ^1.4
- mockery/mockery: ^1.6.10
- phpstan/phpstan: ^2.0.0
- phpunit/phpunit: ^13|^12|^11|^10|^9
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Easily render Laravel API exceptions as consistent JSON:API error responses.
Introduction
The JSON API has a precise response format. This set of classes allows these to be easily created and interrogated, meaning easy and reliable output/input processing.
The floor9design-ltd/json-api-formatter package offers a great way to automatically format these, easing the process
significantly.
However, in real life development generic or system errors can be an afterthought and sometimes left out. This package offers a well-rounded boilerplate for the Laravel framework, so that these are taken care of in a few minutes.
It gives a shared exception renderer.
Features
- Simple setup in Laravel
- Easy use; simply throw an exception inside your Laravel logic and this will be caught and displayed professionally
- Consistent JSON:API responses.
- Standard responses for authentication, authorisation, validation and resource lookup failures.
- Wide range of errors recognised
Requirements
The renderer uses JSON:API Formatter to build error documents.
Documentation
- Installation covers setup.
- Extending covers how to modify or add your own exceptions.
Project status
This README describes the planned first release. The package and linked guides are in development.
Credits
As always - a github watch/star and a follow is appreciated!