setono/twig-cache-purger-bundle
A Symfony bundle that keeps your Twig cache fresh by purging compiled templates automatically—on deploy or when templates change—so you never serve stale markup or manually clear cache directories again. Drop-in integration through Symfony's cache purger contracts.
What it is. A Symfony bundle that invalidates the compiled cache entry for a single Twig template, instead of nuking the whole Twig cache with cache:clear / cache:pool:clear. Small, single-purpose, MIT.
Architecture fit — the headline finding: this is not a Laravel package. The request frames it as a Laravel/PHP package; it is a Symfony bundle. It ships a DI extension, service definitions, and kernel-time registration. A Laravel application has no bundle/kernel concept to hang that on, and Twig is not even the default engine (Blade). Fit is therefore conditional:
rcrowe/twigbridge), because the bundle's registrations still have nowhere to load.Integration feasibility. Install cost is trivially low: composer require, Flex auto-registers, no schema, no data migration, reversal is composer remove + cache clear. That near-zero cost of reversal is the strongest argument for a short, time-boxed spike rather than a formal evaluation cycle.
Technical risk.
| Risk | Severity | Note |
|---|---|---|
| Twig cache layout is an implementation detail, not a public contract | High | Class-name/path derivation can shift across Twig majors. Pin and smoke-test. |
| Non-filesystem Twig cache (Redis/APCu adapter) makes purge a silent no-op | High | Confirm the mechanism before assuming value. |
| Multi-node fleets | High | Deletes a local file only. Without a shared cache dir (NFS/EFS) or fan-out, other pods serve stale templates. |
| Bus factor 1 — Setono, 0 stars, 0 dependents | Medium | No community vetting, no downstream bug reports, no compatibility pressure. |
| Metadata anomaly (release dated 2026-04-13) | Medium | Validate actual tags/commits rather than trusting the listing. |
| Name collision: "purger" implies HTTP/CDN purge | Medium | It does not touch HttpCache, Varnish, Cloudflare, or response caches. Correct stakeholder expectations early. |
| Filesystem-write primitive if exposed operationally | Medium | Authz, CSRF, audit logging and path-traversal guarantees land on our wrapper, not the bundle. |
| Concurrency: deleting a compiled template mid-read | Medium | Test under load; check for transient failures and duplicate recompiles. |
Key questions to answer before commitment.
CacheInterface / LoaderInterface, or hard-coded path assumptions?Stack fit. Primary stack is Laravel/Blade. Treat the package as non-installable there. Two legitimate paths:
Migration path (Path B). Single service → composer require → bundle registration → verify against the staging environment with the highest template count. No DB, no schema, no backfill. Rollback is a composer removal plus a cache clear.
Compatibility gates. Symfony LTS, PHP version, Twig major, and the cache adapter question above. The adapter question is make-or-break: if Twig is not filesystem-cached, the entire value proposition is a no-op and the evaluation ends there.
Sequencing.
Maintenance. MIT, tiny surface area, one vendor. Expect to own it regardless of stars. Budget is near-zero while untouched and unbounded if Twig internals shift. Mitigation: pin versions and keep a one-line CI smoke test that purges a template and asserts recompilation and correct rendering.
Support. No community to lean on — 0 stars, 0 dependents means no downstream bug reports, no ecosystem pressure on compatibility, and effectively "best effort from a small agency" upstream. Assume we are the support tier. Assign a named backend owner; do not let this accrete silently to a platform team that never chose it.
Scaling.
Failure modes to instrument.
@App/foo.html.twig), or non-filesystem cache. Presents as a rendering bug. Assert post-purge and alert.Ramp-up. Reading the source is under an hour; the concept is immediately graspable by any PHP engineer. The real ramp-up cost is domain knowledge — how Twig lays out and warms its cache — which the package does not document. Write it down internally once, or the next engineer re-learns it from scratch.
TPM recommendation. Do not adopt as a dependency for the Laravel estate. Log it as a reference implementation for a ~1-day in-house selective template cache purge utility, gated on three prerequisites: filesystem-backed template cache, a shared cache directory (or fan-out) across nodes, and purge observability. Revisit only if a Symfony runtime enters the estate. The 9.64 score is a code-quality signal on a very small artifact; the 47.36 opportunity score and 0 dependents are the decision-relevant numbers.
How can I help you explore Laravel packages today?