【发布时间】:2016-03-16 14:34:11
【问题描述】:
刚刚使用 symfony2 创建了一个新项目并安装了 FOSRestBundle。 控制器示例:
<?php
namespace ApiBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\Controller\FOSRestController;
class TestController extends FOSRestController
{
public function TestAction()
{
$data = array ('1', '2', '3', 'four'); // get data, in this case list of users.
$view = $this->view($data, 200)
->setTemplate("ApiBundle:Test:test.html.twig")
->setTemplateVar('test')
;
return $this->handleView($view);
}
}
收到错误消息:
You have requested a non-existent service "fos_rest.view_handler".
有人知道吗?
【问题讨论】:
标签: php symfony fosrestbundle