haddowg/json-api

A modern, server-side JSON:API 1.1 library for PHP 8.3+.

Maintainers

Package info

github.com/haddowg/json-api

pkg:composer/haddowg/json-api

Transparency log

Statistics

Installs: 122

Dependents: 2

Suggesters: 0

Stars: 0

Open Issues: 1

v1.0.0 2026-07-13 07:56 UTC

README

A modern, server-side JSON:API 1.1 library for PHP 8.3+.

CI

Part of the jsonapi.rest suite — a complete, spec-compliant JSON:API 1.1 stack for PHP: this framework-agnostic core, a Symfony bundle, a Laravel package, and a typed TypeScript client, bound together by one conformance-tested OpenAPI 3.1 contract.

haddowg/json-api is a typed, framework-agnostic toolkit for building JSON:API 1.1 compliant APIs in modern PHP — serialising resources, parsing and validating requests, negotiating content, and shaping responses exactly as the specification requires, without tying you to any particular framework or data layer.

The design leans on contemporary PHP: readonly value objects, enums, a typed exception hierarchy, PSR-7 v2 and PSR-15 throughout, and a fluent schema layer for declaring a resource type's attributes, relationships, filters, sorts, and validation in one place. First-class support for JSON:API profiles is built in rather than bolted on.

Requirements

  • PHP 8.3, 8.4, or 8.5

Installation

composer require haddowg/json-api

Documentation

The full documentation is published at haddowg.github.io/json-api. Start with Getting started for an end-to-end walkthrough, or browse the documentation index for the reference pages.

Using a framework? The Symfony bundle and Laravel package wrap this core with idiomatic routing, validation, and a reference data layer.

Try it

The worked music-catalog example serves itself — run docker compose up in examples/music-catalog/ and browse the live API at http://localhost:8080/albums. It is also the single source of truth for every documentation snippet.

Contributing

See CONTRIBUTING.md. This project uses Conventional Commits and automated releases via release-please.

Credits

This package began as a derivative work based on woohoolabs/yin, and substantial portions of the codebase derive from it — sincere thanks to Woohoo Labs and the yin contributors for the original library. The fluent schema layer draws inspiration from Laravel JSON:API, whose schema-first developer experience shaped this project's recommended API.

Licence

Released under the MIT Licence, with dual copyright held by Gregory Haddow and Woohoo Labs and contributors (the original woohoolabs/yin authors).