Fosrestbundle: FOS Rest Bundle is incompatible with Sensio Framework Extra Bundle v4.0

Created on 2 Oct 2017  路  6Comments  路  Source: FriendsOfSymfony/FOSRestBundle

Specifically when you use Sensio bundle v4 and set this configuration for FOS Rest:

fos_rest:
    view:
        view_response_listener: true

an exception is thrown from ConfigurationCheckPass:34: You must enable the SensioFrameworkExtraBundle view annotations to use the ViewResponseListener.

This is probably due to the fact that you are checking for the sensio_framework_extra.view.listener service which was either made private or renamed (not sure but it's probably the first case as per their changelog).

Bug Needs Review

Most helpful comment

Simple fix for anyone that needs it:

Throw this in your services.yaml (or config.yml for sf 3.0):

services:
    sensio_framework_extra.view.listener:
        alias: Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener

All 6 comments

I've ran into this today:

Fatal error: Uncaught RuntimeException: You need to enable the parameter converter listeners in SensioFrameworkExtraBundle when using the FOSRestBundle RequestBodyParamConverter in /var/www/symfony/vendor/friendsofsymfony/rest-bundle/DependencyInjection/Compiler/ConfigurationCheckPass.php on line 29

It seems indeed that it depends on stuff that is not available anymore!

Same problem with Sensio Framework Extra Bundle v5.0. I have set view_response_listener to 'force'.

I'm in same boat... using extra bundle v 5.0.1 with view_response_listener: force or true.

Simple fix for anyone that needs it:

Throw this in your services.yaml (or config.yml for sf 3.0):

services:
    sensio_framework_extra.view.listener:
        alias: Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener

@aequasi give a quick fix but the real problem is in bundles.php, u need notice it the Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle must be an after FOS\RestBundle\FOSRestBundle to work properly !

Was this page helpful?
0 / 5 - 0 ratings