简体   繁体   English

Symfony2 FOS Rest 包路由 FileLoaderLoadException 控制器

[英]Symfony2 FOS Rest bundle routing FileLoaderLoadException controller

I have a very strange issue, with my Symfony2 setup.我的 Symfony2 设置有一个非常奇怪的问题。

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.我有一个完全可用的应用程序,想更改我的 routing.yml 配置。

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"). Symfony\\Component\\Config\\Exception\\FileLoaderLoadException" message="在@MyProductBundle/Controller/ 中找不到控制器 "@MyProductBundle/Controller/" 的类(正在从 "/home/myproduct/domains/example/v5 /app/config/routing.yml”)。 Make sure the "MyProductBundle" bundle is correctly registered and loaded in the application kernel class.确保“MyProductBundle”包已正确注册并加载到应用程序内核类中。 If the bundle is registered, make sure the bundle path "@MyProductBundle/Controller/" is not empty.如果捆绑包已注册,请确保捆绑包路径“@MyProductBundle/Controller/”不为空。

When I change the type from "rest" to "annotation", the error disappears.当我将类型从“rest”更改为“annotation”时,错误消失了。

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.使用 FOSRestBundle 时,您目前无法一次导入所有包的控制器。It will be added in FOSRestBundle 2.0 .它将被添加到 FOSRestBundle 2.0 中 Import your controllers individually like in your first example.像在第一个示例中一样单独导入您的控制器。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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