File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -54,9 +54,11 @@ $ composer require neomerx/json-api ~0.3
5454
5555### Basic usage
5656
57+ Assuming you've got an ``` $author ``` of type ``` \Author ``` you can encode it to JSON API as simple as this
58+
5759``` php
5860$encoder = Encoder::instance([
59- Author::class => AuthorSchema::class ,
61+ '\ Author' => '\ AuthorSchema' ,
6062], new JsonEncodeOptions(JSON_PRETTY_PRINT));
6163
6264echo $encoder->encode($author) . PHP_EOL;
@@ -108,6 +110,7 @@ class AuthorSchema extends SchemaProvider
108110### Object hierarchy with included objects
109111
110112``` php
113+ // '::class' constant (PHP 5.5 and above) convenient for classes in namespaces
111114$encoder = Encoder::instance([
112115 Author::class => AuthorSchema::class,
113116 Comment::class => CommentSchema::class,
You can’t perform that action at this time.
0 commit comments