setono/twig-cache-purger-bundle
Composer 安装命令:
composer require setono/twig-cache-purger-bundle
包简介
A Symfony bundle that allows you to purge single templates in the Twig cache
README 文档
README
Purge the cache for individual Twig template files instead of removing the whole cache directory.
Requirements
- PHP 8.2+
- Symfony 6.0/7.0/8.0
- Twig 2.x or 3.x
Installation
composer require setono/twig-cache-purger-bundle
This will install the bundle and enable it if you're using Symfony Flex. If you're not using Flex, add the bundle
manually to bundles.php:
Setono\TwigCachePurgerBundle\SetonoTwigCachePurgerBundle::class => ['all' => true],
Usage
The bundle provides a PurgerInterface service that you can inject into your services to purge individual Twig
template cache files by their logical template name:
use Setono\TwigCachePurgerBundle\Purger\PurgerInterface; final class YourService { public function __construct(private readonly PurgerInterface $purger) { } public function updateTemplate(): void { // Purge the cached compiled version of a specific template $this->purger->purge('emails/welcome.html.twig'); } }
The purger resolves the logical template name to its compiled cache file, invalidates the opcache/APC bytecode cache, and deletes the file. The next time the template is rendered, Twig will recompile it from the source.
统计信息
- 总下载量: 25.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-13