2

I use FOSRESTBundle routing and I want to use parent parameter.

I've found this in this example http://symfony.com/doc/current/bundles/FOSRestBundle/6-automatic-route-generation_multiple-restful-controllers.html#resource-collection

But in my case it doesn't work. When I want to show all my routes by router:debug command, Symfony returns me error:

[Symfony\Component\Config\Exception\FileLoaderLoadException]
The routing file "/home/kamil/public_html/.../routing.yml" contains unsupported keys for "sbg_survey_survey": "parent". Expected one of: "resource", "type", "pre
fix", "pattern", "path", "host", "schemes", "methods", "defaults", "requirements", "options", "condition" in /home/kamil/public_html/.../routing.yml (which is be
ing imported from "/home/kamil/public_html/.../routing_dev.yml").

1 Answer 1

1

Actually I've found solution. Yesterday when I was trying to use it I had some problems, but now it's working correctly.

It's necessary to put these routes to separated file and load this file from app/config/routing.yml

My files:

app/config/routing.yml:

kamil_blog:
    type: rest
    resource: "@KamilBlogBundle/Resources/config/routing.yml"

src/Kamil/BlogBundle/Resources/config/routing.yml:

blog_category:
    resource: "@KamilBlogBundle/Controller/CategoryController.php"
    type:     rest

blog_post:
    resource: "@KamilBlogBundle/Controller/PostController.php"
    type:     rest
    parent:   blog_category
Sign up to request clarification or add additional context in comments.

1 Comment

To clarify this, the important part is the type:rest in the app/config/routing.yml

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.