PHPackages                             wunderwerkio/jsonapi-error - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. wunderwerkio/jsonapi-error

ActiveLibrary[API Development](/categories/api)

wunderwerkio/jsonapi-error
==========================

Simple class to conveniently create a JSON error that complies with the JSON:API specification.

1.0.0(1y ago)05.3k↓39.7%1MITPHPPHP &gt;=8.1CI failing

Since Mar 30Pushed 1y ago2 watchersCompare

[ Source](https://github.com/wunderwerkio/jsonapi-error)[ Packagist](https://packagist.org/packages/wunderwerkio/jsonapi-error)[ RSS](/packages/wunderwerkio-jsonapi-error/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (10)Used By (1)

JSON:API Error
==============

[](#jsonapi-error)

[![Test](https://github.com/wunderwerkio/jsonapi-error/actions/workflows/main.yml/badge.svg)](https://github.com/wunderwerkio/jsonapi-error/actions/workflows/main.yml)

This package provides `JsonApiError` and `JsonApiErrorResponse` classses to conveniently handle errors following the [JSON:API specification](https://jsonapi.org/format/#errors).

The `JsonApiErrorResponse` extends the `JsonResponse` from `symfony/http-foundation`, so this package is meant to be used in projects using that.

**Table of contents:**

- [Install](#install)
- [Usage](#usage)
    - [Return a simple error response](#return-a-simple-error-response)
    - [Return multiple errors](#return-multiple-errors)
    - [Build response from `JsonApiError` objects](#build-response-from-jsonapierror-objects)
- [Local Development](#local-development)
- [Credits](#credits)

Install
-------

[](#install)

Install this package via composer:

```
composer require wunderwerkio/jsonapi-error
```

Usage
-----

[](#usage)

### Return a simple error response

[](#return-a-simple-error-response)

```
