简体   繁体   中英

error between FosRestBundle and SensioFramewordBundle

I installed the two libraries FOSRest and Sensio but I have the following error:

You must enable the SensioFrameworkExtraBundle view annotations to use the ViewResponseListener. Did you forget to install and enable the TwigBundle?

While I do not need Twig since my API will send everything back to json.

I still try to install it but I still have problems.

Here is the configuration for Sensio:

sensio_framework_extra:
router:
    annotations: false
view:
    annotations: true
request:
    converters: true

And for FOSREST:

fos_rest:
body_converter:
    enabled: true
serializer:
    serialize_null: true
view:
    formats: { json: true, xml: false, rss: false }
    view_response_listener: true
format_listener:
    rules:
        - { path: '^/', priorities: ['json'], fallback_format: 'json' }

Nothing very important.

I hope you can help me.

Thanking you

While this is not the most satisfying solution, I ended up installing TwigBundle after a very frustrating hour, just as suggested by the message.

composer require symfony/twig-bundle

This should solve your error.


I say this is not the most satisfying solution because just like you I did not need Twig templating at all so it didn't feel natural to install it. I couldn't take much time to figure out why FOSRest would need this. Does it rely on some Twig code bricks to run? I don't know, this is just the best and quicker workaround I found.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM