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 Laravel Package

reva2/jsonapi

A Laravel/PHP package for building JSON:API-compliant APIs with resource serialization, relationships, includes, filtering, sorting, and pagination. It helps keep responses consistent with the JSON:API specification while fitting into familiar Laravel patterns.

Deep Wiki
Context7

reva2/jsonapi is a Laravel package for building APIs that follow the JSON:API specification. It handles request parsing, resource serialization, and relationship handling so you can return spec-compliant responses without writing boilerplate.

The package integrates with Laravel's routing and Eloquent layers, letting you define API resources that map models to JSON:API documents. Requests for includes, sparse fieldsets, sorting, filtering, and pagination are resolved automatically, while errors are rendered in the standard JSON:API error format.

  • Eloquent-backed resource classes with automatic serialization
  • Support for include and fields[...] query parameters
  • Built-in pagination, sorting, and filtering
  • Standardized error responses and status codes
  • Configurable links and meta objects
Frequently asked questions about Jsonapi
How do I install reva2/jsonapi in a Laravel application?
Install the package with Composer using the reva2/jsonapi package name. Laravel package discovery should register the service provider automatically in most setups. Check the package documentation for any publishable configuration or migration steps, then define your JSON:API resources and routes.
Which Laravel versions does reva2/jsonapi support?
The supported Laravel and PHP versions are defined by the package's Composer constraints. Check the package's composer.json or documentation before installing it in an existing application. If you are on an older or newer Laravel release, verify compatibility first to avoid dependency conflicts.
What does JSON:API compliance mean for my Laravel API?
JSON:API defines a standard document structure for resources, relationships, errors, pagination links, and metadata. A compliant API uses the application/vnd.api+json media type and consistent response shapes so clients can rely on predictable conventions. reva2/jsonapi is intended to handle these standardized responses with less boilerplate in Laravel.
How do I define a JSON:API resource and its attributes?
You typically create resource classes that map your Eloquent models or other data sources to JSON:API resource objects. Attributes and relationships are declared on those resource classes, and the package serializes them into compliant responses. Refer to the package documentation for the exact base classes and method signatures to use.
How are relationships and includes handled by reva2/jsonapi?
You define relationships on your JSON:API resources, such as belongsTo or hasMany associations. Clients can then request related data with the include query parameter, and the package resolves those relationships into the included section of the response. This produces compound documents while keeping relationship definitions centralized.
Can I filter and sort JSON:API responses with this package?
Yes, the package is designed to handle filtering and sorting for JSON:API endpoints. You define which filters and sort fields are allowed so clients can use query parameters without exposing arbitrary database columns. The package then applies those options and returns the results in the standard JSON:API response format.
How does pagination work in reva2/jsonapi?
Pagination is handled as part of the JSON:API response layer, typically using page-based query parameters and standardized links or metadata. You configure the page size and let the package generate the pagination details for clients. Check the documentation for the exact query parameter names and pagination strategy supported.
How do I return JSON:API errors from a Laravel controller?
The package is intended to help return standardized JSON:API error documents with fields such as status, title, detail, and source. You can map validation failures or exceptions into that error format instead of returning ad hoc JSON. Review the package's error handling documentation for the supported exception and response classes.
Is reva2/jsonapi suitable for production use and how should I test it?
Treat it like any Composer dependency: check its release history, maintenance activity, and compatibility with your Laravel and PHP versions before using it in production. Write feature tests that assert the JSON:API document structure, relationships, includes, filtering, sorting, and pagination behavior. Also test error responses and authentication or authorization boundaries around your endpoints.
What are some alternatives to reva2/jsonapi for building JSON:API APIs in Laravel?
Alternatives include laravel-json-api, which is a dedicated JSON:API package for Laravel, and more general tools such as spatie/laravel-query-builder or Fractal combined with custom serializers. Evaluate each option by Laravel version support, documentation, relationship and include handling, filtering capabilities, and ongoing maintenance. Choose the package whose conventions best match your team's API design and testing workflow.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections