From c51fb5709400c84dd303ec92addce3da76b9a3a2 Mon Sep 17 00:00:00 2001 From: Alexey Karapetov Date: Tue, 24 Oct 2017 23:22:03 -0700 Subject: [PATCH 1/3] Update README --- README.md | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index fdc1cc9..baf94a6 100644 --- a/README.md +++ b/README.md @@ -27,22 +27,20 @@ A simple example to illustrate the general idea. This JSON representation from } } ``` -can be built with the following php code (less imports): +can be built with the following php code: ```php setLink('self', '/articles/1/relationships/author'); -$author->setLink('related','/articles/1/author'); +$author->setLink('related', '/articles/1/author'); $articles->setRelationship('author', $author); $articles->setAttribute('title', 'Rails is Omakase'); -$doc = \JsonApiPhp\JsonApi\Document::fromResource($articles); -echo json_encode($doc, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); +echo json_encode(Document::fromResource($articles), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); ``` Please refer to [the tests](./test) for the full API documentation: From a70e69081bdb11fa44a208280560dc95da86b1cb Mon Sep 17 00:00:00 2001 From: Alexey Karapetov Date: Tue, 24 Oct 2017 23:24:38 -0700 Subject: [PATCH 2/3] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index baf94a6..7fe1eff 100644 --- a/README.md +++ b/README.md @@ -34,10 +34,10 @@ can be built with the following php code: use \JsonApiPhp\JsonApi\Document; use \JsonApiPhp\JsonApi\Document\Resource\{Linkage\SingleLinkage, Relationship, ResourceIdentifier, ResourceObject}; -$articles = new ResourceObject('articles', '1'); $author = Relationship::fromLinkage(new SingleLinkage(new ResourceIdentifier('people', '9'))); $author->setLink('self', '/articles/1/relationships/author'); $author->setLink('related', '/articles/1/author'); +$articles = new ResourceObject('articles', '1'); $articles->setRelationship('author', $author); $articles->setAttribute('title', 'Rails is Omakase'); echo json_encode(Document::fromResource($articles), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES); From a054e52afb51db35668d8e3943d8ed14df7c8481 Mon Sep 17 00:00:00 2001 From: Alexey Karapetov Date: Tue, 24 Oct 2017 23:26:23 -0700 Subject: [PATCH 3/3] Update README --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7fe1eff..acc8573 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,9 @@ can be built with the following php code: ```php setLink('self', '/articles/1/relationships/author');