Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Json Api Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API contract standardization (build vs. buy). This package is a serialization layer for the JSON:API specification — it turns domain objects into spec-compliant documents (compound documents, relationships, 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.
  • Multi-client and partner-facing API roadmap. JSON:API pays off when the same API must serve web, mobile, and third-party integrators, and when you want those clients to use off-the-shelf JSON:API client libraries (Ember Data, 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.
  • Reduce bespoke documentation and client rework. If the roadmap includes "ship an external API" or "support integration partners with self-serve docs," a spec-compliant envelope lets you document once and point to jsonapi.org rather than maintaining a custom schema doc that drifts from reality.
  • Content/graph-heavy use cases. The strongest fit is resources with dense relationships — CMS, catalog, org/account hierarchies — where compound documents cut N+1 client round-trips and keep payload shape predictable across features.
  • Decision against adoption (equally valuable). A 2018 final release and ~69 stars is a signal, not a footnote. This package should not anchor a long-lived public API. The realistic outcome of an evaluation is often "adopt the JSON:API spec, but use a maintained implementation" — that is a legitimate and probably correct product decision this assessment supports.
  • Sourcing and maintenance-burden framing. Evaluate as a make-vs-buy-vs-fork: is the saved serialization effort worth taking on a dependency you will likely vendor/fork within 12 months? For a small internal API, that trade is poor; for a throwaway internal tool with a short life, it may be fine.

When to Consider This Package

Consider it when all of the following hold:

  • You have already committed to JSON:API as your public contract — the package is an implementation detail, and swapping it later is contained if you isolate it behind your own response/transformer interface.
  • You are on a PHP stack that can accommodate PSR-7. In Laravel this is a seam, not a given: Laravel speaks 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.
  • The lifespan is bounded and known: internal tooling, a proof of concept, a prototype to validate client-side JSON:API consumption before investing in a maintained library.
  • The team has, or can cheaply get, capacity to vendor and patch PHP-version compatibility. Verify PHP 8.x and your framework version before anything else — a 2018 cut predates PHP 7.3+, and stale dependencies are a security-review blocker in most orgs.

Look elsewhere when:

  • You need current framework support. For Laravel, evaluate 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.
  • You need a lighter, framework-agnostic alternative with more community surface: tobscure/json-api, or league/fractal if you decide you want a flexible transformation layer rather than full spec compliance (a common, defensible downgrade).
  • You just need JSON responses, not JSON:API. If the team has not adopted the spec, Laravel API Resources already solve 90% of the problem with zero new dependencies and native pagination/includes. Do not adopt a spec to justify a library.
  • Your security or dependency policy requires an actively maintained release train (SBOM, CVE response, PHP version support matrix). A single 2018 release will not clear that gate.
  • Your API is small or RPC-flavored. Spec compliance costs surface area in error formats, relationship endpoints, and media-type handling; under ~10 endpoints it is usually net negative.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console