ipub/json-api-document

JSON:API document factory

v0.1.0 2020-03-17 19:58 UTC

This package is auto-updated.

Last update: 2021-04-17 23:16:27 UTC


README

Latest Stable Version Composer Downloads License

Small library for creating json:api document from object.

Installation

The best way to install ipub/json-api-document is using Composer:

$ composer require ipub/json-api-document

Create document

$content = $response->getContent();

$document = new \IPub\JsonAPIDocument\Document(json_encode($content));

Get data type

{
  "links": {
    "self": "http://example.com/articles/1"
  },
  "data": {
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON:API paints my bikeshed!"
    },
    "relationships": {
      "author": {
        "links": {
          "related": "http://example.com/articles/1/author"
        }
      }
    }
  }
}
$type = $document->getResource()->getType(); // articles

etc.

Homepage https://www.ipublikuj.eu and repository http://github.com/iPublikuj/json-api-document.