Невозможно работать с FOSRestBundle

Я пытаюсь использовать Symfony2 и FOSRestBundle, чтобы создать REST-фреймворк, и у меня ничего не получается. .

Я сделал следующее:

в моем файле deps:

[FOSRest]
    git=git://github.com/FriendsOfSymfony/FOSRest.git
    target=fos/FOS/Rest

[FOSRestBundle]
    git=git://github.com/FriendsOfSymfony/FOSRestBundle.git
    target=bundles/FOS/RestBundle

[JMSSerializerBundle]
    git=git://github.com/schmittjoh/JMSSerializerBundle.git
    target=bundles/JMS/SerializerBundle

В моих приложениях/config.yml

fos_rest:
    view:
        formats:
            rss: true
            xml: false
        templating_formats:
            html: true
        force_redirects:
            html: true
        failed_validation: HTTP_BAD_REQUEST
        default_engine: twig


sensio_framework_extra:
    view:
        annotations: false

В моем контроллере:

namespace Rest\WebServiceBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use FOS\RestBundle\View\View;  


class DefaultController extends Controller
{

    public function indexAction($name)
    {


  $view = View::create()
          ->setStatusCode(200)
          ->setData($name);
        return $this->get('fos_rest.view_handler')->handle($view);


    }
}

Когда я перехожу по URL-адресу: http:/ /local.symfony.com/web/app_dev.php/hello/test

Я получаю:

Unable to find template "".
500 Internal Server Error - InvalidArgumentException
2 linked Exceptions: Twig_Error_Loader » Twig_Error_Loader

Документация кажется мне запутанной, и я не могу продолжать. Все, что я хочу, это иметь возможность передать массив данных контроллеру и получить обратно формат JSON. Кто-нибудь может помочь?

12
задан jini 13 May 2012 в 17:30
поделиться