tobscure/json-api
A PHP library for building JSON:API-compliant APIs. It handles resource serialization, relationships, included data, links, pagination, and request parsing, making it easy to add a spec-compliant JSON API layer to Laravel or any PHP application.
What it is: tobscure/json-api is a standalone PHP serializer that turns application objects into JSON:API 1.0 documents — data, included, relationships, links, meta, errors — with serializers, sparse fieldsets, compound documents, and error objects. It is a presentation-layer library, not a framework: it does not route, query, paginate, or validate.
Architecture fit: Good fit only if a JSON:API contract is already demanded — an Ember/jsonapi.js front end, a spec-driven public API, or an existing client that expects compound documents and included semantics. Poor fit for a typical Laravel app doing plain REST/JSON: Laravel API Resources give the same outcome with fewer moving parts and no orphaned dependency. Where it does fit, it fits cleanly at the controller→response boundary and composes with Eloquent without changing domain code.
Integration feasibility: Moderate, with hand-written glue. The package itself is a small, dependency-light library and is understandable in a day. The friction is environmental: the last release is March 2017, so Composer constraints, PHP version ceilings, and Laravel adapter expectations are all stale. The companion tobscure/laravel-json-api integration (service provider, facade, exception handling) is also abandoned, meaning the Laravel-specific wiring — provider registration, exception renderer mapping ValidationException/NotFoundHttpException to JSON:API errors, pagination link generation — is ours to build and own.
Technical risk: High and asymmetric.
Serializable return types, dynamic properties). Needs a verified compatibility pass before any commitment.@atomic operations, revised error codes, and link/pagination refinements. This library will never support them. Locking in means locking clients to 1.0.illuminate/support constraints can block Laravel upgrades, forcing the team to choose between framework security patches and the serializer.Key questions:
laravel-json-api (formerly cloudcreativity/json-api) or neomerx/json-api viable alternatives, and why were they rejected?Stack fit: Treat it strictly as a presenter. Controllers and query objects build and eager-load Eloquent models; serializers only shape output. Do not let include/sparse-fieldset parsing drive query construction without an explicit adapter layer, or the query layer becomes implicit and untestable.
Migration path:
vcs/path repository entry — do not depend on the public Packagist artifact.Stringable, removed helpers), relax composer.json version ceilings, and stand up a CI matrix on the PHP versions actually deployed.errors, and centralize link/meta generation.Compatibility: Verify the illuminate/support constraint against the target Laravel major first — this is the go/no-go gate. Confirm behavior under the framework's HTTP layer (content negotiation, application/vnd.api+json media type) and check for reliance on global helpers removed or deprecated since Laravel 6.
Sequencing: (a) 2–3 day spike on a single representative resource; (b) define conventions for includes, sparse fieldsets, pagination links, and error shape; (c) add contract tests run against a JSON:API schema validator; (d) only then broaden to the full resource surface. Do the fork and CI work before writing new endpoints, not after.
Maintenance: We own it outright. Small codebase (low thousands of lines), so tractable — budget roughly 5–10% of one engineer ongoing, spiking at PHP major upgrades and any spec work. Every upgrade of PHP or Laravel becomes a manual verification task with no upstream to lean on.
Support: None. No maintainer, no advisories, no active issue tracker, no meaningful community momentum since 2017. Institutional knowledge concentrates in whoever performs the fork, which is a single-point-of-failure risk unless the fork is documented and reviewed like first-party code.
Scaling: Serialization is in-process CPU, so horizontal scaling is the standard PHP answer. The real cost is payload and query shape: compound documents grow with include depth, and careless includes produce N+1 queries or oversized included arrays. Enforce a maximum include depth, honor sparse fieldsets at the query level, and consider ETag/edge caching. There is no built-in pagination adapter — pagination correctness is an application responsibility and a recurring source of client-visible bugs.
Failure modes:
Ramp-up: A mid-level Laravel developer is productive in 1–2 days and safe with serializers, includes, and sparse fieldsets in about a week. Add a short internal guide plus fixture-based tests. The longer pole is onboarding the maintainer of the fork, not the consumer — plan for at least two people who can patch it.
How can I help you explore Laravel packages today?