I have a route
/books
,
and I wanna chage it, for example, to
/api/v1/books
So I added to my api_platform.yaml
the following
prefix: api/v1/
And now it works fine, my endpoint available at /api/v1/books
, but I have some problem with frontend, because admin panel /admin
and swagger /docs
doesn't work, it sends me 404 error.(It's worth noting that the raw docs without swagger available on /docs.json
) How can I resolve this problem? Only by configure caddy? Is there any way to config platform?
According to the API Platform's docs available here, there are 2 ways of setting-up prefixes for your routes. First, remove your prefix: api/v1/
as it only sets-up a global prefix, which is not what you want.
Method 1 - via php:
Add #[ApiResource(routePrefix: '/v1')]
in your Book entity class:
#[ApiResource(routePrefix: '/v1')]
class Book
{
//...
}
Method 2 - via yaml:
Create a config file /config/api_platform/resources.yaml
and add this:
App\Entity\Book:
attributes:
route_prefix: /v1