You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache生产环境下Symfony Bundle仅在Twig缓存禁用时加载异常

在Apache生产环境下,Symfony的ch_cookie_consent Bundle存在异常——只有在twig.yml中设置cache: false(禁用Twig缓存)时,该Bundle才能正常加载。


相关配置与代码片段

ch_cookie_consent: 
    categories: ['functional']
    theme: 'dark' # light, dark
    use_logger: true # Logs user actions to database
    position: 'bottom' # top, bottom
    simplified: false # When set to true the user can only deny or accept all cookies at once
    http_only: true # Sets HttpOnly on cookies
    #form_action: $routeName # When set, xhr-Requests will only be sent to this route. Take care of having the route available.
    csrf_protection: true # The cookie consent form is csrf protected or not

2. 基础模板引入代码

{{ render_esi(path('ch_cookie_consent.show_if_cookie_consent_not_set', { 'locale' : app.request.locale })) }}

3. 疑似崩溃代码段

$response = new Response(
            $this->twigEnvironment->render('@CHCookieConsent/cookie_consent.html.twig', [
                'form'       => $this->createCookieConsentForm()->createView(),
                'theme'      => $this->cookieConsentTheme,
                'position'   => $this->cookieConsentPosition,
                'simplified' => $this->cookieConsentSimplified,
            ])
        );

4. 异常触发配置(twig.yml)

twig:
    cache: false

注:问题已修复,详见下方评论。

内容的提问来源于stack exchange,提问作者Claod

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.30 04:25:15