Releases: lode/jsonapi
v2.1.0: extensions, arrays of links, @-members (supporting specification v1.1)
Support for v1.1 of the JSON:API specification, including:
Extensions via profiles
Extending a document structure with profiles. See an example profile and a specific cursor pagination example:
$profile = new CursorPaginationProfile();
$document->applyProfile($profile);Array of links under a single key
E.g. for type error links:
$errorObject->appendTypeLink('https://...');@-members
Which can be used for JSON-LD for example. They can be added to any object:
$anything->addAtMember('foo', 'bar');v2.0.0: New specification-based interface (next to the human-friendly interface)
v2's main feature is having a strict specification-based interface for building documents. This is added next to keeping the human-friendly interface for people who don't know the spec, and don't want to get to know it.
Other features include:
- Explicitly empty relationships
- Jsonapi object in output to help discovery
- Unit and output tests
- php7 ready (php5.6 is still supported, php5.4 and 5.5 are dropped)
This release is breaking backwards compatibility with v1. However, most of the interface and output stayed the same. See the UPGRADE doc on how to upgrade.
The main reasons for the BC break are:
- the jsonapi specification started to recommend CamelCase in their v1.1
- php7 marks
resourcea reserved keyword, thus the main class name changed - the current implementation offers too little flexibility for future changes in the specification
See the examples for more information.
Note: v2.0 of the library doesn't yet support v1.1 of the specification. A v2.1 is coming up and will support v1.1 of the specification.
v2.0.0-beta: New specification-based interface (next to the human-friendly interface)
v2's main feature is having a strict specification-based interface for building documents. This is added next to keeping the human-friendly interface for people who don't know the spec, and don't want to get to know it.
Further php7 is supported next to php5, and unit tests and json-output tests are added for the whole library.
This release is breaking backwards compatibility with v1. However, most of the interface and output stayed the same. See the UPGRADE doc on how to upgrade.
The main reasons for the BC break are:
- the jsonapi specification started to recommend CamelCase in their v1.1, thus all method names changed
- php7 marks
resourcea reserved keyword, thus the main class name changed (php5 is still supported, however support for php5.4 and php5.5 is dropped) - the current implementation offers too little flexibility for future extensions of the spec
See the examples for more information.
Note: v2.0 of the library doesn't yet support v1.1 of the specification.
v1.5.1 Fix for free format relationships
v1.5.0: better link objects
This has some much needed improvements on how jsonapi handles link objects.
Mainly, it makes it way easier to follow the spec for adding links, see #10 for the structure change. Basically you can now:
- Use
add_link('search', 'https://google.com')and get:
{
"links": {
"search": "https://google.com"
}
}- Or use
add_link('search', 'https://google.com', $meta=['label'=>'Look it up'])and get:
{
"links": {
"search": {
"href": "https://google.com",
"meta": {
"label": "Look it up"
}
},
}
}Before, you had to create this switch and structure manually.
You can still pass an array or object as second argument and skip the metadata to use your own structure for the link object.
Other changes
- a
selflink can also have metadata by usingadd_self_link_meta()orset_self_link() - an error object's
aboutlink can also contain metadata - links can be added to errors and collection documents (both now also have
add_link()andfill_links() - custom links can be added to a resource document's root-level
v1.4.1: fix to-many relationships to follow the spec
A fix for to-many relationships to follow the spec.
v1.4.0: improve nesting and to-many relationships
A bunch of small but important improvements to relationships:
- Relationships now can also be of the to-many type, thanks @Pierozi! (#17, see example)
- Nesting relationships; when adding a relationship which has a relationship on itself, the latter is also added to the included set of the parent (#27, see example)
- Nesting meta-data; root-level meta of a resource is passed to a collection's root-level meta, and root-level meta of a relationship is passed to its parent (#28)
Another unrelated change:
- Allowing responses with only meta data and no primary data, thanks @tstrijdhorst! (#26)
v1.3.1: fixes exceptions
- exceptions threw an exception since jsonp support was added
- exceptions out of direct control which used non-400/500 error codes couldn't be added to the errors collection
v1.3.0: adds jsonp support
This makes it possible to send the jsonapi response in a jsonp callback container.
Thanks @lthh89vt for adding this!