Symfony2 FOSRestBundle handleView() doesn't work

Viewed 1050

Just created a new project with symfony2 and installed FOSRestBundle. Controller example:

<?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);       
    }

}

Got error message:

You have requested a non-existent service "fos_rest.view_handler".

Does anyone have an idea about this?

1 Answers
Related