Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is idiomatic way to clear whole cache in Twig since 1.22.x?

Tags:

idioms

php

twig

Since 1.22.0 version of Twig, method Twig_Environment::clearCacheFiles() is deprecated. However, I didn't found anywhere (nor in documentation, nor in repo tickets, nor here on SO) something which can replace this deprecated method.

So what is the idiomatic (and not deprecated) way to clear all cache files now?

Clearing those files via implementing own function seems to be pretty weird.

like image 958
Tyranron Avatar asked Nov 09 '22 03:11

Tyranron


1 Answers

So there is no new idiomatic way to clear all cache files.
Twig project maintainers leave it for library users on their own. The arguments are:

The argument was that Twig itself will only support filesystem cache (due to opcache). Thus clear() would be the same as removing the cache folder manually. Thus it doesn't need to be in the interface. So you have to clear your cache either manually or write the method yourself.

More details may be read in relevant issue early referred by @alain-tiemblo in comments.

like image 156
Tyranron Avatar answered Nov 14 '22 22:11

Tyranron