Skip to content

Releases: lode/jsonapi

v2.1.0: extensions, arrays of links, @-members (supporting specification v1.1)

03 Mar 12:23
623b0aa

Choose a tag to compare

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)

03 Mar 11:18
c80ec0b

Choose a tag to compare

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 resource a 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)

17 Feb 19:03
4700695

Choose a tag to compare

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 resource a 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

17 Jan 23:11
09cc3f7

Choose a tag to compare

Fixes free format relationships on resources #32, thanks @vvdt for reporting.

v1.5.0: better link objects

30 Jun 14:37
e75477b

Choose a tag to compare

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:

  1. Use add_link('search', 'https://google.com') and get:
{
	"links": {
		"search": "https://google.com"
	}
}
  1. 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 self link can also have metadata by using add_self_link_meta() or set_self_link()
  • an error object's about link can also contain metadata
  • links can be added to errors and collection documents (both now also have add_link() and fill_links()
  • custom links can be added to a resource document's root-level

v1.4.1: fix to-many relationships to follow the spec

23 Mar 13:21
b94cfae

Choose a tag to compare

A fix for to-many relationships to follow the spec.

v1.4.0: improve nesting and to-many relationships

23 Mar 13:21
5cfae1a

Choose a tag to compare

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

09 Aug 14:03
d7dc6c3

Choose a tag to compare

  • 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

15 Jun 06:03

Choose a tag to compare

This makes it possible to send the jsonapi response in a jsonp callback container.
Thanks @lthh89vt for adding this!

v1.2.1: fixes exception during exception handling

23 Jan 13:43

Choose a tag to compare