File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,28 @@ Or in XML:
228
228
229
229
In all the previous examples, you can safely remove the ` method ` because the method name always match the operation name.
230
230
231
+ ### Prefixing All Routes of All Operations
232
+
233
+ Sometimes it's also useful to put a whole resource into its own "namespace" regarding the URI. Let's say you want to
234
+ put everything that's related to a ` Book ` into the ` library ` so that URIs become ` library/book/{id} ` . In that case
235
+ you don't need to override all the operations to set the path but configure a ` routePrefix ` for the whole entity instead:
236
+
237
+ ``` php
238
+ <?php
239
+ // api/src/Entity/Book.php
240
+
241
+ use ApiPlatform\Core\Annotation\ApiResource;
242
+
243
+ /**
244
+ * ...
245
+ * @ApiResource("attributes"={"routePrefix"="/library"})
246
+ */
247
+ class Book
248
+ {
249
+ //...
250
+ }
251
+ ```
252
+
231
253
## Subresources
232
254
233
255
Since ApiPlatform 2.1, you can declare subresources. A subresource is a collection or an item that belongs to another resource.
You can’t perform that action at this time.
0 commit comments