Skip to content

Fix routePrefix documentation #528

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 9, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions core/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ In all the previous examples, you can safely remove the `method` because the met

Sometimes it's also useful to put a whole resource into its own "namespace" regarding the URI. Let's say you want to
put everything that's related to a `Book` into the `library` so that URIs become `library/book/{id}`. In that case
you don't need to override all the operations to set the path but configure a `routePrefix` for the whole entity instead:
you don't need to override all the operations to set the path but configure the `route_prefix` attribute for the whole entity instead:

```php
<?php
Expand All @@ -241,15 +241,16 @@ you don't need to override all the operations to set the path but configure a `r
use ApiPlatform\Core\Annotation\ApiResource;

/**
* ...
* @ApiResource("attributes"={"routePrefix"="/library"})
* @ApiResource(routePrefix="/library")
*/
class Book
{
//...
}
```

Alternatively, the more verbose attributes syntax can be used `@ApiResource(attributes={"route_prefix"="/library"})`

## Subresources

Since ApiPlatform 2.1, you can declare subresources. A subresource is a collection or an item that belongs to another resource.
Expand Down