PHPackages                             bitnetic/jsonapi - 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. bitnetic/jsonapi

ActivePackage[API Development](/categories/api)

bitnetic/jsonapi
================

A laravel-based jsonapi.org compatibility package

2.0.0(2y ago)05191PHP

Since May 11Pushed 2y ago1 watchersCompare

[ Source](https://github.com/bitnetic-software/jsonapi)[ Packagist](https://packagist.org/packages/bitnetic/jsonapi)[ RSS](/packages/bitnetic-jsonapi/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (1)Versions (9)Used By (0)

JsonApi.org compability package for Laravel 5.5+
================================================

[](#jsonapiorg-compability-package-for-laravel-55)

This package is intended to provide an easy way to achieve compatibility with the API standards defined at . Currently, only the top-level structure () is supported, but ongoing work strives for a more complete coverage of the standard.

How to install it
-----------------

[](#how-to-install-it)

You can install the package via *composer*. For Laravel 5.5 up to 6.x run:

```
$ composer require bitnetic/jsonapi "0.1.*"

```

For Laravel 7 run:

```
$ composer require bitnetic/jsonapi "^2.0"

```

JsonApi comes with a config file named *config/jsonapi.php*. This file is deployed to the central laravel configuration directory using the *vendor:publish* command:

```
$ php artisan vendor:publish --provider "Bitnetic\JsonApi\JsonApiServiceProvider"

```

Next, extend your exception handler with JsonApi standard responses. Note that this example uses the Laravel 7 signature that uses `Throwable`instead of `Exception` that was used in Laravel 5 and 6.

```
/**
 * Render an exception into an HTTP response.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Throwable  $exception
 * @return \Illuminate\Http\Response
 */
public function render($request, Throwable $exception)
{
    return JsonApiExceptionHandler::render($request, $exception)
        ?? parent::render($request, $exception);
}

```

How to use it
-------------

[](#how-to-use-it)

This JsonApi package is minimal-invasive to Laravel. Just use HTTP resources within your controllers and extend them from `JsonApiResource`.

This is an example controller method:

```
/**
 * @return UserResource
 */
public function getUser(Request $request)
{
    return new UserResource($request->user());
}

```

You can also use collections in a `list()`-method by calling `UserResource::collect($myUsers);`.

Put extra data into the response
================================

[](#put-extra-data-into-the-response)

You can always add your own data into the `meta` or `errors` field, or return a different HTTP status code. The package just makes sure that the status code is mapped additionally as a `status` field within the meta block.

```
return new UserResource($myUser, ['type' => 'admin'], $exception->errors(), 404);

```

How to write an appropriate resource
====================================

[](#how-to-write-an-appropriate-resource)

Take a look at the following example:

```
class UserResource extends JsonApiResource
{
    public function toArray($request)
    {
        return [
            'name' => $this->name,
            'email' => $this->email,
            'password' => $this->when(
                $request->user() ... e.g.,
                MySecureTokenFactory::wrap($this->password),
        ];
    }
}

```

In a resource like `UserResource($user)`, you can access the underlying user object by using `$this`.

You can also take a look the included `ExampleResource` and adopt it to your needs.

The outcome
===========

[](#the-outcome)

The formatted Json-Api-Response from the examples above should produce something like this:

```
{
  "data": {
    "name": "John Doe",
    "email": "john@example.com"
  },
  "meta": {
    "status": 200
    "success": true
  }
}

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 92.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~282 days

Recently: every ~464 days

Total

8

Last Release

949d ago

Major Versions

0.1.6 → 2.0.02023-10-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/358a3bdb5f4b73c0d583ba8782d27c17678557d7141a6c584b2b7990f04bdbdf?d=identicon)[bitnetic](/maintainers/bitnetic)

---

Top Contributors

[![denudge](https://avatars.githubusercontent.com/u/812769?v=4)](https://github.com/denudge "denudge (12 commits)")[![wnkchristopher](https://avatars.githubusercontent.com/u/34061788?v=4)](https://github.com/wnkchristopher "wnkchristopher (1 commits)")

### Embed Badge

![Health badge](/badges/bitnetic-jsonapi/health.svg)

```
[![Health](https://phpackages.com/badges/bitnetic-jsonapi/health.svg)](https://phpackages.com/packages/bitnetic-jsonapi)
```

###  Alternatives

[darkaonline/l5-swagger

OpenApi or Swagger integration to Laravel

2.9k34.0M112](/packages/darkaonline-l5-swagger)[echolabsdev/prism

A powerful Laravel package for integrating Large Language Models (LLMs) into your applications.

2.3k388.3k10](/packages/echolabsdev-prism)[sburina/laravel-whmcs-up

WHMCS API client and user provider for Laravel

271.3k](/packages/sburina-laravel-whmcs-up)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
