cerbero / json-api-error
Laravel package to standardize API errors in compliance with the JSON:API spec.
Installs: 1 164
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- illuminate/http: >=9.0
- illuminate/support: >=9.0
- illuminate/testing: >=9.0
Requires (Dev)
- orchestra/testbench: >=7.0
- pestphp/pest: ^2.0
- phpstan/phpstan: ^1.9
- scrutinizer/ocular: ^1.8
- squizlabs/php_codesniffer: ^3.0
- tightenco/duster: ^2.0
README
{ "errors": [ { "status": "422", "title": "Unprocessable Content", "detail": "The name field must be a string.", "source": { "pointer": "/name" } }, { "status": "422", "title": "Unprocessable Content", "detail": "The name field must be at least 2 characters.", "source": { "pointer": "/name" } } ] }
Laravel package to standardize API error responses in compliance with the JSON:API spec, providing:
- consistency: ensure uniform API error responses across all Laravel apps, adhering to a widely used standard
- automation: handle Laravel-specific and common HTTP exceptions automatically
- simplicity: focus solely on error responses without the need to implement the full JSON:API spec
- zero configuration: install the package with no additional configuration required
- customization: optionally register custom handlers, map errors to HTTP statuses or merge default data
- localization: translate JSON:API errors into any language
- testability: test error responses using the built-in testing tools
- debugging: inspect the original message and trace when an unexpected error occurs
๐ฆ Install
Via Composer:
composer require cerbero/json-api-error
๐ฎ Usage
Note
Work in progress... ๐๏ธ
- implement
links
- write documentation
- reach 100% code coverage
- tag stable version
๐ Change log
Please see CHANGELOG for more information on what has changed recently.
๐งช Testing
composer test
๐ Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
๐งฏ Security
If you discover any security related issues, please email andrea.marco.sartori@gmail.com instead of using the issue tracker.
๐ Credits
โ๏ธ License
The MIT License (MIT). Please see License File for more information.