- What is tobyz/json-api-server and how does it work?
- tobyz/json-api-server is a PHP implementation of the JSON:API specification and a Laravel package for building compliant APIs. You define a Schema for each resource's attributes, relationships, filters, sorts, and pagination, plus an Adapter that bridges it to your data source. The server then derives serialization, compound documents, includes, relationship endpoints, filtering, sorting, pagination links, and structured errors.
- How do I install and configure tobyz/json-api-server in Laravel?
- Install it with Composer, register your schemas, and mount the server at an /api prefix. You will write one Schema and one Adapter per resource plus an authorization hook, and wire the PSR-7/PSR-15-style middleware into Laravel. Nothing is exotic, but the fully automated promise depends on correct schema configuration.
- Which Laravel and PHP versions does tobyz/json-api-server support?
- The evaluation targets Laravel 9 through 11 on PHP 8.1 and newer, and the core also fits any PSR-15-compatible PHP stack. Check the package's composer.json constraints for the exact Laravel and PHP versions it declares. Because it is pre-1.x, confirm support before upgrading major Laravel versions.
- Does tobyz/json-api-server support relationships, includes, sparse fieldsets, filtering, sorting, and pagination?
- Yes. Schema definitions drive relationship endpoints such as /articles/1/relationships/author, compound documents, include resolution, and sparse fieldsets, while attributes, filters, sorts, and pagination are also declared in the schema. The server derives the spec-compliant responses from your Schema and Adapter classes.
- How do I connect tobyz/json-api-server to Eloquent models?
- Write one Adapter class per resource that bridges your Schema to Eloquent or a query builder, implementing fetch, filter, sort, and paginate behavior. The Schema describes attributes, relationships, filters, sorts, and pagination options. The cost is one schema plus one adapter per resource, not one per endpoint.
- Is tobyz/json-api-server production-ready and actively maintained?
- It is the engine behind Flarum's production API, so it is battle-tested by one large consumer. But it has roughly 70 GitHub stars, no recorded dependents, and a single primary maintainer. Treat it as mature code with bus-factor and pre-1.x API-stability risk, not a vendor-backed product.
- How does authorization work with tobyz/json-api-server?
- Authorization is intended to be hooked around the server, for example with per-schema policy middleware or an authorization hook in your Laravel app. The evaluation flags this as a key question and asks whether a reference implementation exists. You own that wiring; it is not automatic from the schema.
- How do I test JSON:API endpoints built with tobyz/json-api-server?
- The evaluation flags test coverage as something to verify: confirm whether the package's suite tests JSON:API spec conformance or only happy-path serialization. In your app, test relationship linkage, include resolution, sparse fieldsets, filtering, sorting, pagination links, and structured error objects. Because the server derives behavior from schemas and adapters, also unit-test each Schema and Adapter.
- What JSON:API version does tobyz/json-api-server target, and does it support JSON:API 1.1?
- It implements JSON:API v1.0. The evaluation lists whether it will track 1.1 as an open question; 1.1 affects things like the filter query parameter family and relationship handling. Confirm the target version before relying on 1.1-only features.
- How does tobyz/json-api-server compare to Laravel API resources and other JSON:API packages?
- If you want zero-config REST scaffolding, Laravel API resources plus a JSON:API serializer or a package like spatie/laravel-json-api may fit better. tobyz/json-api-server is strongest when you want a spec-compliant server driven by schemas and adapters, or need PSR-15 portability. It is a poor fit for teams unwilling to learn the JSON:API spec.