php - Symfony2 FOS Rest 捆绑路由 FileLoaderLoadException Controller

标签 php rest symfony fosrestbundle

我的 Symfony2 设置遇到了一个非常奇怪的问题。

我正在开发一个安静的网络服务,并且想要设置路由。

我有一个完全运行的应用程序,并且想更改我的routing.yml 配置。

工作配置

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

当我将其更改为:

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

我收到以下错误:

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.

当我将类型从“rest”更改为“annotation”时,错误消失。

我做错了什么?我找不到它,而且我的搜索一无所获。

非常感谢!

最佳答案

当前,使用 FOSRestBundle 时无法一次性导入 bundle 的所有 Controller 。 It will be added in FOSRestBundle 2.0 。像第一个示例一样单独导入 Controller 。

enter image description here

关于php - Symfony2 FOS Rest 捆绑路由 FileLoaderLoadException Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32541027/

相关文章:

java - 为什么类图不包括所有类?

php - 向仅包含数字的日期字符串添加斜杠

php - MySQL 和 PHP - 让 href 记住以前的变量

json - 为 ASP .NET MVC 4 WebAPI 序列化 (XML/JSON) 更改内部对象的名称

forms - Symfony 不验证对象约束

php - 使用基于 Symfony 2 的网站处理生产中的 PHP 错误

php - Sonata Admin 搜索功能

php - PDO 大于小于

javascript - Base64 数据;我应该在实际的 base64 之前包含 "data:xxx"吗?

c++ - 无法使用 Reddit API 通过仅应用程序 OAuth 检索访问 token