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
Jsonapi Bundle

Jsonapi Bundle Laravel Package

reva2/jsonapi-bundle

A Symfony bundle for building JSON:API-compliant APIs with Doctrine ORM integration, including resource serialization, relationship includes, filtering, sorting, pagination, sparse fieldsets, and standardized error responses.

View on GitHub
Deep Wiki
Context7

JSON API support for your Symfony REST API

Frequently asked questions about Jsonapi Bundle
What is reva2/jsonapi-bundle used for?
It is a Symfony bundle for building JSON:API-compliant APIs with minimal boilerplate. It handles response serialization, relationship includes, sparse fieldsets, filtering, sorting, pagination, and mapping validation errors into JSON:API error objects. Controllers stay focused on business logic instead of hand-building payloads. Resources are exposed through simple attribute or annotation configuration.
How do I install reva2/jsonapi-bundle with Composer?
Install it with composer require reva2/jsonapi-bundle and then register the bundle in your Symfony application kernel or bundles.php. Because it is a Symfony bundle, setup assumes a Symfony kernel and Doctrine ORM entities. Confirm the PHP and Symfony constraints in its composer.json before adding it to an existing project, and clear the container cache after installation.
Does this package work with Laravel?
No, reva2/jsonapi-bundle is built as a Symfony bundle and depends on Symfony bundle registration and Doctrine ORM integration rather than Laravel service providers. Laravel applications do not load Symfony bundles through package discovery, so installing it will not wire up routing, serialization, or resource metadata automatically. Teams evaluating JSON:API for Laravel should treat this package as a reference implementation and pick a Laravel-native option instead. Also verify the Composer framework constraints, since a Symfony bundle will conflict with a Laravel-only dependency set.
Which PHP and framework versions are supported?
The bundle targets Symfony with Doctrine ORM, so support is defined by the Symfony and PHP constraints declared in the package's composer.json. Always read those constraints for the exact release you install instead of assuming Laravel-style version ranges. If you maintain a Laravel application, check whether your PHP runtime and framework major version can coexist with the bundle's Symfony dependencies in the same Composer resolution. Run composer why-not against the version you want to see the blocking constraints quickly.
How do I expose a Doctrine entity as a JSON:API resource?
Resources are configured with attributes or annotations, so you declare the resource type and the fields you want exposed directly on or near the entity. The bundle then handles serialization into standard JSON:API resource objects with ids, types, attributes, and relationships. Keep exposure explicit rather than dumping every column, since sparse fieldsets only reduce an already-declared field set. Review the configuration docs for relation mapping before you publish endpoints.
How do relationship includes and compound documents work?
Relationships declared in your resource configuration can be requested through the standard JSON:API include query parameter. The bundle resolves the requested paths and emits related resources into the top-level included array, following the specification's compound document rules. Unrequested relationships are represented as relationship links or identifiers rather than being fully serialized. This keeps payloads predictable and avoids accidental N+1 style over-fetching.
Are sparse fieldsets, filtering, sorting, and pagination supported out of the box?
Yes, these query features are part of the bundle rather than something you implement per controller. Sparse fieldsets map the fields[type] parameter onto your declared resource fields, while sorting, filtering, and pagination follow JSON:API query conventions. Because filtering and sorting translate into query criteria against Doctrine, review which fields you allow to be filtered so clients cannot probe unintended columns. Combine these features with sensible page size limits for public APIs.
How are validation errors returned in the response?
Validation failures are mapped to JSON:API error objects, so clients receive a consistent errors array instead of a framework-specific exception payload. Each error can carry a status, title, detail, and source pointer identifying the offending attribute. That consistency is valuable for front-end clients that already parse JSON:API documents. Make sure your exception listeners do not intercept these errors before the bundle formats them.
What changed in version 3.1.2 and is it safe to upgrade?
The 3.1.2 release is a patch-level fix that corrects a missing alias for a factory interface, which matters for container resolution and bootstrapping. It is scoped as a semver patch, so it should be backward compatible, but confirm the affected container key is not one your application overrides. Upgrade by updating the Composer constraint, running a targeted composer update, and clearing the container and package caches. Roll out to staging or a canary first and watch for boot or resolution errors.
How do I test and maintain an API built with this bundle?
Write functional tests that assert the full JSON:API document shape, including type, id, attributes, relationships, and the included array for compound documents. Add coverage for sparse fieldsets, error formatting, and filtered or sorted collections, since those behaviors are easy to regress when resource configuration changes. On maintenance, pin to a known good release or allow patch updates, refresh the container cache after every deploy, and keep a rollback path. If you need a Laravel-native approach instead, compare against JSON:API-focused packages in the Laravel ecosystem before committing.
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