Skip to content

๐Ÿ’ฅ Laravel package to standardize API errors in compliance with the JSON:API spec.

License

Notifications You must be signed in to change notification settings

cerbero90/json-api-error

Repository files navigation

๐Ÿ’ฅ JSON:API Error

Author PHP Version Laravel Version Build Status Coverage Status Quality Score PHPStan Level Latest Version Software License PER Total Downloads

{
  "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 [email protected] instead of using the issue tracker.

๐Ÿ… Credits

โš–๏ธ License

The MIT License (MIT). Please see License File for more information.

About

๐Ÿ’ฅ Laravel package to standardize API errors in compliance with the JSON:API spec.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Languages