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

3 Answers 3


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


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.

  • 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, 2013 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, 2013 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, 2014 at 13:02
  • 2
    Via drush: drush ev '\Drupal\Core\PhpStorage\PhpStorageFactory::get("twig")->deleteAll();'
    – Tim
    Jan 10, 2018 at 15:00

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.

  • This doesn't work anymore - you just need drush cr
    – Jono
    Mar 2, 2023 at 14:56


drush twig:compile

twig:compile (twigc) Compile all Twig template(s).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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