Getting started
Installation
Require the package, publish what you want to customise, and render errors as JSON:API.
Require the package
Terminal
composer require ark4ne/laravel-json-apiThe package requires ark4ne/laravel-api-revisions, which renders the values and holds the
revisions of your API. Its service provider is discovered by Laravel.
Publish the configuration (optional)
Terminal
php artisan vendor:publish --provider="Ark4ne\JsonApi\Laravel\JsonApiServiceProvider" --tag=config
config/jsonapi.php is documented key by key; see the configuration reference.
The format of dates, the strictness of the values and the revisions are set in config/revisions.php of
ark4ne/laravel-api-revisions.
Render errors as JSON:API
bootstrap/app.php
use Ark4ne\JsonApi\Laravel\JsonApi;
use Illuminate\Foundation\Configuration\Exceptions;
->withExceptions(function (Exceptions $exceptions) {
JsonApi::renderErrors($exceptions);
})
See Errors & content negotiation for the jsonapi route middleware.
Other files you can publish
| Tag | Publishes | To |
|---|---|---|
jsonapi-stubs | The stub of make:jsonapi-resource | stubs/jsonapi-resource.stub |
jsonapi-lang | The validation messages | lang/vendor/jsonapi/ |
Terminal
php artisan vendor:publish --tag=jsonapi-stubs
php artisan vendor:publish --tag=jsonapi-lang
Coding agents
Agents such as Claude Code or Cursor can load the skills shipped in vendor/ark4ne/laravel-json-api/skills/:
laravel-json-api (the rules, every helper, tested recipes) and laravel-json-api-upgrade (the migration from 1.x).