简体   繁体   中英

Symfony2 FOS Rest bundle routing FileLoaderLoadException controller

I have a very strange issue, with my Symfony2 setup.

I'm working on a restful webservice and would like to setup routing.

I have a fully working application and woud like to change my routing.yml config.

Working configuration

my_product:
    resource: My\Bundle\ProductBundle\Controller\DefaultController
    type:     rest
    prefix:   /

When I change that to:

my_product:
    resource: "@MyProductBundle/Controller/"
    type:     rest
    prefix:   /

I get the following error:

Symfony\\Component\\Config\\Exception\\FileLoaderLoadException" message="Can't find class for controller "@MyProductBundle/Controller/" in @MyProductBundle/Controller/ (which is being imported from "/home/myproduct/domains/example/v5/app/config/routing.yml"). Make sure the "MyProductBundle" bundle is correctly registered and loaded in the application kernel class. If the bundle is registered, make sure the bundle path "@MyProductBundle/Controller/" is not empty.

When I change the type from "rest" to "annotation", the error disappears.

What am I doing wrong? I can't find it out and my searches lead to nothing.

Many thanks in advance!

You can't currently import all of a bundle's controllers at once when using FOSRestBundle.It will be added in FOSRestBundle 2.0 . Import your controllers individually like in your first example.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM