nilportugues/json-api
A PHP package for building JSON API (jsonapi.org) compliant responses, with Laravel support. It transforms Eloquent models and collections into standardized resources, handling includes, pagination, links, meta and error objects so your API follows the spec without manual serialization.
included, sparse fieldsets, pagination links, standardized error objects) and returns them as PSR-7 responses. The buy-side argument is real: hand-rolling JSON:API compliance is weeks of work per endpoint family and is exactly the kind of undifferentiated plumbing a team should not own.json-api-normalizer, etc.) instead of bespoke SDKs. Adopting it is a contract decision, not a library decision — this package is just one way to honor that contract.Consider it when all of the following hold:
Illuminate\Http\Response/JsonResponse, so you need a PSR-7 bridge (e.g. symfony/psr-http-message-bridge) or adapter layer. Budget for that integration work explicitly — it is the hidden cost of "PSR-7 valid responses" in an otherwise Laravel-native codebase.Look elsewhere when:
laravel-json-api/json-api (active, first-class Eloquent integration, validation, filtering, authorization) or spatie/laravel-json-api. Both target the same spec with maintained releases.tobscure/json-api, or league/fractal if you decide you want a flexible transformation layer rather than full spec compliance (a common, defensible downgrade).To executives: There is a real, quantified cost in every product that ships an external or multi-client API — agreeing on payload shape, documenting it, and keeping every client in sync. The JSON:API standard exists to eliminate that cost, and it is a standard our clients can consume with off-the-shelf tooling. This specific package, however, is a thin 2018-era implementation with negligible community adoption; recommending it as production infrastructure would create maintenance and security exposure we cannot staff away. My recommendation: adopt the standard, not this package. We pursue JSON:API compliance using a maintained Laravel-native implementation, which preserves the strategic benefit (interoperability, cheaper client integrations, spec-based documentation) without inheriting an unmaintained dependency. This package is useful to us as a reference implementation and a fast way to prototype JSON:API output inside a spike — not as a foundation.
To engineering: Treat this as a spike tool and a readable reference for JSON:API document structure, not a runtime dependency. The PSR-7 output is genuinely valuable if your stack already speaks PSR-7, but in Laravel it means adding a bridge and an adapter layer around every controller — real work, and work you would throw away on migration. Before any spike, verify PHP 8 compatibility and confirm whether the dependency tree installs cleanly under your lockfile constraints; if it does not install in under an hour, stop and use laravel-json-api/json-api directly. If we do spike it, put the transformers behind our own interface so the swap is a one-file change.
Sequencing recommendation: decide the contract first (JSON:API vs. plain REST + API Resources), then pick the library. Reversing that order — picking this package because it is available and small — is how teams end up owning a fork of an abandoned serializer eighteen months later.
How can I help you explore Laravel packages today?