Skip to content

Commit 7d0f6c7

Browse files
docs(extending-jsonld-context): compatibility with laravel (#2090)
1 parent bcfd40e commit 7d0f6c7

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

core/extending-jsonld-context.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
<p align="center" class="symfonycasts"><a href="https://symfonycasts.com/screencast/api-platform/json-ld?cid=apip"><img src="../symfony/images/symfonycasts-player.png" alt="JSON-LD screencast"><br>Watch the JSON-LD screencast</a></p>
66

77
API Platform provides the possibility to extend the JSON-LD context of properties. This allows you to describe JSON-LD-typed
8-
values, inverse properties using the `@reverse` keyword and you can even overwrite the `@id` property this way. Everything you define
9-
within the following annotation will be passed to the context. This provides a generic way to extend the context.
8+
values, inverse properties using the `@reverse` keyword, and you can even overwrite the `@id` property this way.
9+
Everything you define within the following annotation will be passed to the context. This provides a generic way to
10+
extend the context.
1011

1112
```php
1213
<?php
13-
// api/src/Entity/Book.php
14-
namespace App\Entity;
14+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
15+
namespace App\ApiResource;
1516

1617
use ApiPlatform\Metadata\ApiProperty;
1718
use ApiPlatform\Metadata\ApiResource;
@@ -71,8 +72,8 @@ It's also possible to replace the Hydra context used by the documentation genera
7172

7273
```php
7374
<?php
74-
// api/src/Entity/Book.php
75-
namespace App\Entity;
75+
// api/src/ApiResource/Book.php with Symfony or app/ApiResource/Book.php with Laravel
76+
namespace App\ApiResource;
7677

7778
use ApiPlatform\Metadata\ApiResource;
7879
use ApiPlatform\Metadata\Get;
@@ -88,8 +89,9 @@ class Book
8889

8990
```yaml
9091
# api/config/api_platform/resources.yaml
92+
# The YAML syntax is only supported for Symfony
9193
resources:
92-
App\Entity\Book:
94+
App\ApiResource\Book:
9395
operations:
9496
ApiPlatform\Metadata\Get:
9597
hydraContext: { foo: 'bar' }
@@ -98,12 +100,13 @@ resources:
98100
```xml
99101
<?xml version="1.0" encoding="UTF-8" ?>
100102
<!-- api/config/api_platform/resources.xml -->
103+
<!-- The XML syntax is only supported for Symfony -->
101104

102105
<resources xmlns="https://api-platform.com/schema/metadata/resources-3.0"
103106
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
104107
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0
105108
https://api-platform.com/schema/metadata/resources-3.0.xsd">
106-
<resource class="App\Entity\Book">
109+
<resource class="App\ApiResource\Book">
107110
<operations>
108111
<operation class="ApiPlatform\Metadata\Get">
109112
<hydraContext>

0 commit comments

Comments
 (0)