-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsimple_doc.php
29 lines (27 loc) · 935 Bytes
/
simple_doc.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php declare(strict_types=1);
require_once __DIR__.'/../vendor/autoload.php';
use JsonApiPhp\JsonApi\Attribute;
use JsonApiPhp\JsonApi\DataDocument;
use JsonApiPhp\JsonApi\Link\RelatedLink;
use JsonApiPhp\JsonApi\Link\SelfLink;
use JsonApiPhp\JsonApi\Link\Url;
use JsonApiPhp\JsonApi\Relationship;
use JsonApiPhp\JsonApi\ResourceIdentifier;
use JsonApiPhp\JsonApi\ResourceObject;
use JsonApiPhp\JsonApi\SingleLinkage;
echo json_encode(
new DataDocument(
new ResourceObject(
'articles',
'1',
new Attribute('title', 'Rails is Omakase'),
new Relationship(
'author',
new SingleLinkage(new ResourceIdentifier('author', '9')),
new SelfLink(new Url('/articles/1/relationships/author')),
new RelatedLink(new Url('/articles/1/author'))
)
)
),
JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES
);