cloudcreativity/laravel-json-api
A Laravel package for building JSON:API compliant APIs with Eloquent support, offering resource routing, validation, filtering, sorting, pagination, sparse fieldsets, and relationship includes out of the box.
Architecture fit
cloudcreativity/laravel-json-api is a full implementation of the JSON:API 1.0 specification (document structure, compound documents, relationship endpoints, sparse fieldsets, sort/filter/pagination conventions, error objects) layered onto Laravel's router, Eloquent, and validation stack. It is an opinionated replacement for the controller/serializer layer, not an add-on: you declare per-resource Schemas, Adapters, and Validators, and the package generates routes and request handling from that declaration.
That makes fit a binary product decision rather than a technical preference:
application/vnd.api+json, or a mobile client team that wants compound documents and relationship endpoints "for free" rather than hand-rolling them.JsonResource plus a thin serializer is lower total cost of ownership.Integration feasibility
Mechanically low friction: Composer install, service-provider auto-discovery, config publish, and Artisan generators (make:json-api:schema, :adapter, :validators) scaffold the resource classes. Route registration is a single call per API namespace, and existing auth middleware (Sanctum/Passport) attaches at the route-group level, so authentication does not need rework. Models opt in via the JsonApiResource contract or via adapters for stricter separation.
The real cost is cognitive, not mechanical. A spike of 5–10 engineer-days covering one read-only resource with two relationships, sparse fieldsets, and pagination is enough to produce a credible go/no-go and an effort estimate for the remainder.
Technical risk
related links, pagination defaults). Under-testing here produces subtle contract breaks for clients.Key questions
Stack fit Assumes Laravel 8–10 with PHP 8.x, Eloquent, Sanctum or Passport, and MySQL/Postgres. The composability that matters is at the edges: authorization policies, request-scoped middleware, and pagination/caching are all Laravel-native and compose normally. Confirm exact Composer constraints against our target Laravel version before committing — this is the single most common blocker.
Migration path Use a strangler pattern rather than a cutover:
/api/v2) alongside existing controllers.This preserves client contracts, contains blast radius to a single resource per release, and gives a clean rollback (unmount the route group).
Compatibility
Sequencing
Do not start Sprint 1 before the ADR is signed — the lock-in decision is the expensive one to reverse.
Maintenance Recurring cost is version-tracking, not bug-fixing: budget a standing allocation each time Laravel ships a major, plus a quarterly check on upstream activity and open-issue trajectory. If upstream stalls, the fallback is a small internal fork (Apache-2.0 permits it) — cheap to start, expensive to sustain, so define the threshold in advance. Resource classes themselves are declarative and low-churn once stable.
Support No commercial support tier. Support is GitHub issues and community channels, which means internal expertise is the actual support contract. Mitigate by designating two engineers as owners (one primary, one backup) and documenting the resource-generation conventions in a short internal runbook. Onboarding a third engineer later is materially harder if that runbook doesn't exist.
Scaling Request-path overhead is encoding/decoding and query construction — measurable but rarely the bottleneck at typical API volumes. The genuine scaling risk is N+1 queries from under-declared eager loading: the package will happily serialize relationships it wasn't told to preload. Enforce a policy that every relationship exposed in a Schema has a corresponding eager-load declaration, and add query-count assertions to the test suite. There is no built-in HTTP caching; ETag/Cache-Control and response caching must be layered on top and are worth doing early for read-heavy endpoints.
Failure modes
Accept/Content-Type for application/vnd.api+json producing 406/415 surprises for clients.Ramp-up Expect 2–4 weeks for a mid-level Laravel developer to reach productive independence, front-loaded on the mental model shift (declare Schemas/Adapters/Validators instead of writing controllers). The spike should produce the internal runbook as a first-class deliverable, not a byproduct. Given the modest ecosystem and thin community coverage relative to mainstream Laravel patterns, plan for self-sufficiency rather than relying on tutorials and Stack Overflow.
How can I help you explore Laravel packages today?