PHPackages                             floor9design/json-api-formatter - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. floor9design/json-api-formatter

ActiveLibrary[HTTP &amp; Networking](/categories/http)

floor9design/json-api-formatter
===============================

A set of classes that allow for creating JSON API compliant objects

2.0.5(4mo ago)1234.8k↓71.6%3MITPHPPHP &gt;=8.0CI passing

Since Aug 17Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/floor9design-ltd/json-api-formatter)[ Packagist](https://packagist.org/packages/floor9design/json-api-formatter)[ Docs](https://github.com/floor9design-ltd/json-api-formatter)[ RSS](/packages/floor9design-json-api-formatter/feed)WikiDiscussions master Synced yesterday

READMEChangelog (10)Dependencies (4)Versions (44)Used By (0)

json-api-formatter
==================

[](#json-api-formatter)

[![Latest Version](https://camo.githubusercontent.com/67d19b52be8160b11eb92c39e75f220dd763ac3edfd8dfcef4f66bad2ca565f4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465723f696e636c7564655f70726572656c6561736573267374796c653d706c6173746963)](https://github.com/floor9design-ltd/json-api-formatter/releases)[![Packagist](https://camo.githubusercontent.com/2712cbefd1216d4264ff20ce2232f6f982b07a40b5bf17a9ac108204d8daaa35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f6f723964657369676e2f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://packagist.org/packages/floor9design/json-api-formatter)[![Software License](https://camo.githubusercontent.com/10955426da15c7ed27f262e19d2eddeb65055494880cc858e8fc0792d5e15d1c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d706c6173746963)](LICENCE.md)

[![Build Status](https://camo.githubusercontent.com/5735f1866ae091f8bd9ce85e37c25a3fd1b41265115177cd3d9e86567df5f0c4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://codecov.io/gh/floor9design-ltd/json-api-formatter)

[![Github Downloads](https://camo.githubusercontent.com/131e672a4b0b533da7f6065721b5c5d701ca3efcf15d3b831c4cc20df7514236/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465722f746f74616c3f7374796c653d706c6173746963)](https://github.com/floor9design-ltd/json-api-formatter)[![Packagist Downloads](https://camo.githubusercontent.com/41dac56dafac6e34a5c1d01122c8120b30ad4983f302afe96ed405e46d8856c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f6f723964657369676e2f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://packagist.org/packages/floor9design/json-api-formatter)

A set of classes that allow for creating JSON API compliant objects

Introduction
------------

[](#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.

Output is as simple as:

```
use Floor9design\JsonApiFormatter\Models\JsonApiFormatter;

// setup a data resource:
$data_resource = new DataResource(
    'NCC-1701-A',
    'starship',
    ['name' => 'Enterprise']
);

$response = $json_api_formatter->dataResourceResponse($data_resource);
// a json-api string, good for direct output
```

Other responses and elements, such as errors, meta data, links and source elements are all supported.

For more examples, see [usage](docs/project/usage.md).

Features
--------

[](#features)

[![Latest Version](https://camo.githubusercontent.com/67d19b52be8160b11eb92c39e75f220dd763ac3edfd8dfcef4f66bad2ca565f4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465723f696e636c7564655f70726572656c6561736573267374796c653d706c6173746963)](https://github.com/floor9design-ltd/json-api-formatter/releases)[![Packagist](https://camo.githubusercontent.com/2712cbefd1216d4264ff20ce2232f6f982b07a40b5bf17a9ac108204d8daaa35/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f666c6f6f723964657369676e2f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://packagist.org/packages/floor9design/json-api-formatter)

The classes offer:

- easy methods to wrap and unwrap content
- default values and settings out of the box, improving the quality of response
- fluent programming approach, allowing objects to be built on the fly

Install
-------

[](#install)

Via Composer/packagist

[![Packagist Downloads](https://camo.githubusercontent.com/41dac56dafac6e34a5c1d01122c8120b30ad4983f302afe96ed405e46d8856c6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f666c6f6f723964657369676e2f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://packagist.org/packages/floor9design/json-api-formatter)

```
composer require floor9design/json-api-formatter
```

Via git

[![Github Downloads](https://camo.githubusercontent.com/131e672a4b0b533da7f6065721b5c5d701ca3efcf15d3b831c4cc20df7514236/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f646f776e6c6f6164732f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465722f746f74616c3f7374796c653d706c6173746963)](https://github.com/floor9design-ltd/json-api-formatter)

```
git clone https://github.com/floor9design-ltd/json-api-formatter.git
```

Or:

```
git clone git@github.com:floor9design-ltd/json-api-formatter.git
```

Usage
-----

[](#usage)

This is discussed in the usage document.

- [usage](docs/project/usage.md)

Class reference
---------------

[](#class-reference)

The class documentation is located in the class reference:

- [class reference](docs/project/class_rererence.md)

Setup
-----

[](#setup)

There are no specific config setup steps required. The class should autoload in PSR-4 compliant systems. If you are using the class on its own, simply include it however is most appropriate.

Testing
-------

[](#testing)

[![Build Status](https://camo.githubusercontent.com/f79193976447a4054fbd1be13589c2e3f7c3430377c0af41d731623a48710920/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://travis-ci.com/github/floor9design-ltd/json-api-formatter)[![Build Status](https://camo.githubusercontent.com/5735f1866ae091f8bd9ce85e37c25a3fd1b41265115177cd3d9e86567df5f0c4/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f666c6f6f723964657369676e2d6c74642f6a736f6e2d6170692d666f726d61747465723f7374796c653d706c6173746963)](https://codecov.io/gh/floor9design-ltd/json-api-formatter)

Tests can be run as follows:

- `./vendor/phpunit/phpunit/phpunit`

Static analysis/code review can be performed by using [phpstan](https://phpstan.org/):

- `./vendor/bin/phpstan`

The following tests and also creates code coverage (usually maintained at 100%)

- `./vendor/phpunit/phpunit/phpunit --coverage-html docs/tests/`

Note, the following are very useful for validating/testing outputs:

- [Validator](https://www.jsonschemavalidator.net/)
- [Official definition/format](https://jsonapi.org/format/)

Credits
-------

[](#credits)

- [Rick](https://github.com/elb98rm)

Changelog
---------

[](#changelog)

A changelog is generated here:

- [Change log](CHANGELOG.md)

License
-------

[](#license)

This software is available under the MIT licence.

- [License File](LICENCE.md)

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance75

Regular maintenance activity

Popularity37

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 79.8% 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 ~47 days

Recently: every ~84 days

Total

43

Last Release

135d ago

Major Versions

0.6.0 → 1.0.02022-02-28

1.3.1 → 2.0.02025-03-17

PHP version history (2 changes)0.1.0PHP &gt;=7.4

2.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/ca241b0576f1570f1de86d5cb18429e6a662cc165c1e798d321754a549d65a27?d=identicon)[elb98rm](/maintainers/elb98rm)

---

Top Contributors

[![elb98rm](https://avatars.githubusercontent.com/u/2630101?v=4)](https://github.com/elb98rm "elb98rm (331 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (84 commits)")

---

Tags

apirestjsonapifloor9design

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/floor9design-json-api-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/floor9design-json-api-formatter/health.svg)](https://phpackages.com/packages/floor9design-json-api-formatter)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M338](/packages/api-platform-core)[api-platform/openapi

Models to build and serialize an OpenAPI specification.

404.8M93](/packages/api-platform-openapi)[api-platform/symfony

Symfony API Platform integration

384.5M127](/packages/api-platform-symfony)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M218](/packages/api-platform-metadata)[api-platform/state

API Platform state interfaces

274.9M135](/packages/api-platform-state)[api-platform/hydra

API Hydra support

274.7M22](/packages/api-platform-hydra)

PHPackages © 2026

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