Search code examples
apisymfonynamespacesfosrestbundle

Symfony2 FosRestBundle root api url


I've been looking at the FOS-Rest-Bundle documentation in order to develop an API of mine. The problem is that I would like the API to be under api/ and there doesn't seem to be any option to achieve this.

Is there a way? how would I do this?

Thanks


Solution

  • You can add a prefix in your routing. See http://symfony.com/doc/current/book/routing.html#prefixing-imported-routes

    For example :

    api_rest:
        type: rest
        prefix: /api
        resource: "@MyBundle/Resources/config/rest_routes.yml"