Download the PHP package alsvanzelf/jsonapi without Composer
On this page you can find all versions of the php package alsvanzelf/jsonapi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alsvanzelf/jsonapi
More information about alsvanzelf/jsonapi
Files in alsvanzelf/jsonapi
Package jsonapi
Short Description Human-friendly library to implement JSON:API without needing to know the specification.
License MIT
Homepage https://github.com/lode/jsonapi
Informations about the package jsonapi
jsonapi
A simple and human-friendly library for api servers (php serving json).
It allows you to generate json output according to the JSON:API v1.1 standard, while being easy to understand for people without knowledge of the jsonapi standard.
The JSON:API standard makes it easy for clients to fetch multiple resources in one call and understand the relations between them. Read more about it at jsonapi.org.
Installation
Use Composer require to get the latest stable version:
The library supports, and is is tested on, php versions 5.6, 7 and 8.
Upgrading from v1
If you used v1 of this library, see UPGRADE_1_TO_2.md on how to upgrade.
Getting started
A small resource example
Which will result in:
A collection of resources with relationships
Which will result in:
Turning an exception into jsonapi
Which will result in:
This can be useful for development. For production usage, you can better construct an ErrorsDocument
with only specific values.
Using extensions and profiles
The Atomic Operations extension and the Cursor Pagination profile come packaged along. Any 3rd party of self-made extension can be applied with:
Which will result in:
A similar flow can be used for profiles.
Other examples
Examples for all kind of responses are in the /examples directory.
Features
This library supports v1.1 of the JSON:API specification.
It has support for generating & sending documents with:
- single resources
- resource collections
- to-one and to-many relationships
- errors (easily turning exceptions into jsonapi output)
- v1.1 extensions and profiles
- v1.1 @-members for JSON-LD and others
Also there's tools to help processing of incoming requests:
- parse request options (include paths, sparse fieldsets, sort fields, pagination, filtering)
- parse request documents for creating, updating and deleting resources and relationships
Next to custom extensions/profiles, the following official extensions/profiles are included:
- Atomic Operations extension (specification)
- Cursor Pagination profile (specification)
Plans for the future include:
Contributing
If you use the library, please ask questions or share what can be improved by creating an issue.
For bugs issues or Pull Requests are welcome!
Licence
MIT
All versions of jsonapi with dependencies
ext-json Version *