8

Twig generates classes for its templates. These classes are effectively caches by being written to disc.

Generally speaking, one probably doesn't need to bother with the details of how the twig templates are handled, but there could be cases when the Twig templates must be manually re-generated. (Similar to the need for the Registry rebuild module in D7)

If it's relevant, I'm asking because I'm stuck with an error that looks like this:

Fatal error: Class '__TwigTemplate_ddad913164239ac659c2bca09b3a49a5' not found in core/lib/Drupal/Core/Template/TwigEnvironment.php on line 107

6

Not sure why you get that specific error, but have a look at drupal_flush_all_caches(), which does

PhpStorageFactory::get('twig')->deleteAll();

That said, I'm not sure if this will solve your problem, as I've never seen that error, not sure how it could end up expecting a class that is not there.

|improve this answer|||||
  • Interesting that you say you have never seen it, as I've seen it before as well. Then I just re-installed though, and it worked. Now not even that helps. – Letharion Aug 9 '13 at 20:27
  • 2
    In this case, this turned out to be bad ownership of the settings file... Thanks for the helpful error message Drupal ;) – Letharion Aug 12 '13 at 9:12
  • 1
    In my case it was the permissions of the public files folder that werent set correctly. I installed the website using drush, which in my local environment is a different user than the web server user. The solutions was to adjust the folder permissions. – batigolix Sep 30 '14 at 13:02
  • 1
    Via drush: drush ev '\Drupal\Core\PhpStorage\PhpStorageFactory::get("twig")->deleteAll();' – Tim Jan 10 '18 at 15:00
1

I was seeing this Twig error in my error log, when attempting to access a Drupal 8.x site after it had been installed with drush with drush si --db-url=mysql://root:root@localhost/mysite -y. So to correct the issue, again with drush, simply clear the cache:

drush cr all 

Additionally, after this, if your new Drupal 8.x site doesn't appear to have any CSS styles, then this is likely due to the apache/httpd user not having write permissions to sites/default/files.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.