Search code examples
apachesymfonycachingtwigbundle

(Apache prod) Symfony bundle only loading when twig cache disabled


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

my base template inclusion :

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

and the part of the code where it seems crashing :

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

It's not working but only when setting twig.yml

twig:
    cache: false

FIXED : see comment below.


Solution

  • Fixed: Symfony project var/cache/prod wrong authorisations.

    I created a resetcache.sh that cleared Symfony cache, warmup then set authorisations on the prod folder cache and its content. I used chown, chgrp, chmod so the owner and the groupe set were www-data (apache) and everyone can read/write/execute all inside this folder. Until this: Twig was not able to write its cache... that's why the include part was missing.