haddowg / json-api-laravel
Laravel package for haddowg/json-api: idiomatic routing, content negotiation, validation, and an Eloquent data layer for spec-compliant JSON:API 1.1 endpoints.
Requires
- php: ^8.3
- haddowg/json-api: ^1.0
- illuminate/auth: ^12.0 || ^13.0
- illuminate/config: ^12.0 || ^13.0
- illuminate/console: ^12.0 || ^13.0
- illuminate/container: ^12.0 || ^13.0
- illuminate/contracts: ^12.0 || ^13.0
- illuminate/database: ^12.0 || ^13.0
- illuminate/events: ^12.0 || ^13.0
- illuminate/http: ^12.0 || ^13.0
- illuminate/routing: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- illuminate/validation: ^12.0 || ^13.0
- nyholm/psr7: ^1.8
- psr/http-factory: ^1.0
- psr/http-message: ^2.0
- symfony/psr-http-message-bridge: ^7.0 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- larastan/larastan: ^3.0
- opis/json-schema: ^2.6
- orchestra/testbench: ^10.0 || ^11.0
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^12.0
- symfony/intl: ^7.0
Suggests
- opis/json-schema: Enables the testing kit's SchemaConformanceTrait (validate real responses against the generated OpenAPI component schemas in your test suite) and the TestResponse::assertJsonApiSpecCompliant() macro / the optional schema_validation document linter (^2.6).
README
Part of the jsonapi.rest suite — a complete, spec-compliant JSON:API 1.1 stack for PHP: a framework-agnostic core, a Symfony bundle, this Laravel package, and a typed TypeScript client, bound together by one conformance-tested OpenAPI 3.1 contract.
A Laravel package that makes haddowg/json-api
idiomatic in a Laravel application: declare a JSON:API type as a class and get the standard
endpoint set — spec-compliant JSON:API 1.1 documents, content negotiation, validation, policy
authorization, and an Eloquent data layer — with no controller, handler, or serializer
wired by hand.
It is the Laravel twin of the Symfony bundle: both build on the same framework-agnostic core and project a byte-identical OpenAPI document for an identical domain, so a client generator consumes either backend unchanged.
Requirements
- PHP
^8.3(8.3 / 8.4 / 8.5) - Laravel
^12.0 || ^13.0(via theilluminate/*components)
Install
composer require haddowg/json-api-laravel
php artisan vendor:publish --tag=jsonapi-config # optional — customise servers, pagination, OpenAPI
The service provider is auto-discovered and core is pulled in transitively — there is nothing to register by hand.
Documentation
Full documentation is published at haddowg.github.io/json-api-laravel. Start with install and getting started, or browse the documentation index.
Core concepts (fields, relations, constraints, response value objects) live in the core documentation.
Demo
docker compose up serves the full twelve-type music-catalog example over HTTP — browse
http://localhost:8080/api/albums and the interactive OpenAPI docs at
http://localhost:8080/docs. See the
Docker guide.
License
Released under the MIT License.