Fosrestbundle: Error : "You must enable the SensioFrameworkExtraBundle view annotations"

Created on 18 Jan 2018  路  9Comments  路  Source: FriendsOfSymfony/FOSRestBundle

Hello,

I use Symfony 2.8 with FOSRestBundle 1.8, (i can't update, this is fixed because i am in a collab work).

I have this error when i call a controller method that returns a view Response (by View::create($data)) :
RuntimeException in ConfigurationCheckPass.php line 34:
You must enable the SensioFrameworkExtraBundle view annotations to use the ViewResponseListener.

I read all issues concerning configuration of the bundle and problems with FrameworkExtraBundle, but no solution work for me ...

In my config.yml file, i have :

# fos_rest configuration
fos_rest:
    param_fetcher_listener: true
    body_listener: true
    format_listener: true
    view:
        view_response_listener: 'force'
        formats:
            xml: true
            json : true
        templating_formats:
            html: true
        force_redirects:
            html: true
        failed_validation: HTTP_BAD_REQUEST
    routing_loader:
        default_format: json
        include_format: false
sensio_framework_extra:
    view: { annotations: false }

Thanks for your help :)

Most helpful comment

Does it change anything if you change the config for SensioFrameworkExtraBundle to something like this:

sensio_framework_extra:
    view: { annotations: true }

All 9 comments

Does it change anything if you change the config for SensioFrameworkExtraBundle to something like this:

sensio_framework_extra:
    view: { annotations: true }

Yes, il already tried this, and it throw this error :
Attempted to call an undefined method named "getTemplate" of class "SymfonyBundleFrameworkBundleTemplatingTemplateReference".
Stack Trace
in vendorfriendsofsymfonyrest-bundleEventListenerViewResponseListener.php at line 119 -
$view->setData($parameters);
}
if ($configuration && ($template = $configuration->getTemplate()) && !$view->getTemplate()) {
if ($template instanceof TemplateReferenceInterface) {
$template->set('format', null);
}
at ViewResponseListener ->onKernelView ()

This is the first error i had since the beginning.

You probably also need to install and enable the TwigBundle.

TwigBundle is already installed, but i don't think the problem comes form Twig itself ...
Do you have others ideas or things that i can check to continue debug ?

+1 I have this error too

Can you try the latest master? If that still does not work, are you able to create a small project that allows to reproduce the issue?

1878 might be related.

Hello,
I don't know how, but today it works ... I have not changed anything in a long time.
Thanks anyway for your answers ;)

Thanks for the feedback. Closing here then.

Was this page helpful?
0 / 5 - 0 ratings