jasonroman/twig-extension-bundle
A Symfony bundle that integrates custom Twig extensions into your templating layer, making it easy to register and use additional filters, functions, and tags while keeping extension configuration centralized.
Architecture fit — poor, with a caveat. This is a Symfony2 bundle, not a Laravel package. Symfony bundles depend on Kernel bootstrapping, DependencyInjection\Extension classes, compiler passes, and service tags (twig.extension) to auto-register into Twig. Laravel has no bundle system, no compiler-pass pipeline, and no Twig in core — it ships Blade. Adopting this package means introducing two layers Laravel does not natively have: a Twig runtime (via rcrowe/twigbridge or equivalent) and a Symfony DI shim to satisfy the bundle's registration contract. The bundle itself is likely thin — a container of Twig filters/functions — so the ratio of integration machinery to actual functionality is unfavorable.
Integration feasibility — technically possible, practically not worth it. The bundle's real IP is the extension classes (string/date/formatting filters). Those classes are plausibly framework-agnostic and can be lifted out and registered manually in a Laravel service provider (Twig::addExtension) with a few hours of work. Trying to consume the bundle as a bundle is the expensive path. Rough sizing:
Technical risk — high, concentrated in lifecycle rather than security. Symfony 2.x is end-of-life (2.8 LTS support ended 2018), and the package's composer constraints almost certainly target PHP 5.x and Twig 1.x/2.x. Under PHP 8+ you should expect hard failures from removed functions, implicit nullable parameters, and dynamic property deprecations. Twig 3 removed Twig_Extension and the getName() contract, which breaks the bundle's registration model outright. The supply-chain surface is small (MIT, few or no transitive dependencies, zero dependents means no inherited attack surface), but the maintenance risk is total: 0 stars, 0 dependents, no evidence of recent releases, tests, or CI. There is no community signal to validate correctness of the filter implementations — date/timezone and string-manipulation filters are exactly where subtle correctness bugs hide and where you want test coverage you can inspect.
Key questions for the maintainer (if any engagement is contemplated):
Stack fit — mismatch by default; resolve it at the boundary. A Laravel application's rendering layer is Blade. Twig in Laravel is a deliberate, minority architectural choice supported by rcrowe/twigbridge, which is itself low-activity and lags Twig major versions. Before any code is written, the TPM decision is not "how do we install this bundle" but "do we want Twig in this application at all." If the answer is no — the correct default — this package is out of scope and its functionality should be expressed as Blade directives or a small helper/service class. If the answer is yes, this bundle still does not fit, because TwigBridge expects plain Twig extensions, not Symfony bundles.
Recommended migration path (extract, don't integrate):
app/Support/Twig/ (or rewrite as Blade directives), strip namespace and DI references, and conform to Twig's AbstractExtension API.AppServiceProvider and pass them to the Twig environment, or register Blade directives via Blade::directive().Compatibility. Assume breakage at three seams: PHP version (5.x-era signatures vs. 8.x strictness), Twig major version (1.x/2.x class names and getName() vs. Twig 3's AbstractExtension), and Symfony component versions if any are transitively required. Verify each seam with a throwaway composer require in an isolated branch before committing to a path — that spike is half a day and settles the question definitively.
Sequencing. Decision spike (composer resolve + class inspection) → Twig-in-Laravel go/no-go → extract/port → golden tests → ship. Front-load the spike; it is the cheapest point at which to kill the initiative.
Maintenance — you will own this code regardless of the decision. With zero dependents and zero stars, there is no upstream to absorb PHP/Twig upgrades, no security response process, and no issue triage. If the filters ship, budget recurring time for every PHP minor and Twig major upgrade. The extract-and-own path makes this explicit and bounded (a few hundred lines you control); the bundle-integration path makes it implicit and entangled with a DI shim nobody understands.
Support. No community, no documentation beyond the README, no Stack Overflow corpus. Internal documentation of each ported filter's semantics is mandatory, because the original behavior is only discoverable by reading source. Assign a named owner; unowned ported utility code rots quickly.
Scaling. A non-issue. Twig extensions are compile-time registrations against a cached template graph; runtime cost is identical to any other filter. No memory, connection-pool, or concurrency concerns. Do not let this dimension influence the decision.
Failure modes to design against:
composer.json after extraction, blocking future PHP upgrades. Mitigation: remove it in the same PR that ports the code.Ramp-up. The code volume is small and the concepts (Twig extension registration, Blade directives) are familiar to any mid-level Laravel engineer — roughly one sprint-week including tests and documentation. The ramp-up cost is not learning the package; it is unlearning the assumption that a Symfony bundle can be installed into Laravel. Set that expectation before work begins.
Recommendation. Do not adopt the bundle as a dependency. Evaluate the underlying filters as a source to be extracted, and only if Twig is already (or is deliberately being) introduced into the stack. The expected value of the integration path is negative: high uncertainty, no upstream support, and a small amount of portable logic that is cheaper to own outright.
How can I help you explore Laravel packages today?