setono/twig-cache-purger-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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

Latest Version Software License build codecov

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固