【发布时间】:2017-10-01 18:30:49
【问题描述】:
我正在使用 Symfony 3.3,我正在尝试使用 FOSRestController 来制作 API。
这是我的配置文件:
# SensioFrameworkExtra Configuration
sensio_framework_extra:
view: { annotations: false }
# FOSRest Configuration
fos_rest:
format_listener:
rules:
- { path: '^/api', priorities: ['json'], fallback_format: 'json' }
- { path: '^/', stop: true }
view:
view_response_listener: true
控制器:
<?php
namespace AppBundle\Api;
use FOS\RestBundle\Controller\Annotations as REST;
use FOS\RestBundle\Controller\FOSRestController;
use FOS\RestBundle\View\View;
class MyController extends FOSRestController
{
/**
* @REST\Get("/some-url")
* @REST\View()
*
* @return View
*/
public function getSomethingAction()
{
$view = View::create();
return $view;
}
}
问题是关于view_response_listener,我收到此错误消息:
(1/1) RuntimeException
You must enable the SensioFrameworkExtraBundle view annotations to use the ViewResponseListener.
路由:
api_something:
type: rest
resource: AppBundle\Api\MyController
bundle 已经安装并添加到 AppKernel.php 文件中
有什么可以帮助我的吗?
谢谢
【问题讨论】:
-
您发布的配置文件清楚地显示注释设置为 false?
标签: php symfony fosrestbundle