Apache生产环境下Symfony Bundle仅在Twig缓存禁用时加载异常
在Apache生产环境下,Symfony的ch_cookie_consent Bundle存在异常——只有在twig.yml中设置cache: false(禁用Twig缓存)时,该Bundle才能正常加载。
相关配置与代码片段
1. ch_cookie_consent.yml 配置
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
相关产品推荐
相关产品推荐

