FosRestBundle和SensioFramewordBundle之间的错误

问题描述 投票:0回答:1

我安装了两个库FOSRest和Sensio,但是我有以下错误:

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

虽然我不需要Twig,因为我的API会将所有内容发送回json。

我仍然尝试安装它,但我仍然有问题。

以下是Sensio的配置:

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

对于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' }

没什么非常重要的。

我希望你能帮助我。

感谢您

php symfony4 fosrestbundle
1个回答
0
投票

虽然这不是最令人满意的解决方案,但我在一个非常令人沮丧的时刻之后最终安装了TwigBundle,正如消息所暗示的那样。

composer require symfony/twig-bundle

这应该可以解决您的错误。


我说这不是最令人满意的解决方案,因为就像你一样,我根本不需要Twig模板,因此安装它并不自然。我无法花太多时间弄清楚为什么FOSRest需要这个。它是否依赖于一些Twig代码砖来运行?我不知道,这只是我找到的最好,更快的解决方法。

© www.soinside.com 2019 - 2024. All rights reserved.