stinger-soft/twig-extensions
Twig Extensions for PHP adds handy filters, functions and tags to the Twig templating engine, making it easier to write expressive templates in Laravel and other PHP projects. A lightweight package that plugs into existing Twig setups with minimal configuration.
Architecture fit. This package operates at the Twig layer, not the Laravel layer. Laravel's first-class view engine is Blade; Twig is only reachable through a community bridge (rcrowe/twigbridge and its forks), which has historically lagged Laravel majors. Stinger Soft is a Symfony-oriented shop, so the artifact is likely shaped as a Symfony Extension plus Bundle — the Bundle has no meaning in Laravel, and package discovery will not wire it. The realistic integration is "instantiate the extension classes and register them on the Twig\Environment that the bridge builds," which is manual glue, not a supported integration. That is acceptable for a small, well-audited extension; it is not acceptable for something you expect to Just Work.
Integration feasibility. Feasible with effort. Two paths: (a) adopt twigbridge, publish its config, and add the extension classes to the extensions array; (b) skip the bridge and construct a Twig environment directly for a narrow rendering surface (e.g., email/PDF templates). Path (b) is lower risk if you only need Twig for one subsystem. Both require the package to be autoloadable under the target PHP version and Twig major, and require verifying whether the package ships a Laravel ServiceProvider or only a Symfony Bundle. With zero dependents, there are no reference integrations to copy, so this is discovery work, not configuration work.
Technical risk.
twig/extensions filters (filter, map, reduce, find, split, sort, etc.). A package of "common filters, functions and tests" may largely duplicate core, and duplicate registration is a hard failure — Twig throws on conflicting filter names at environment boot, which surfaces as a 500 on every request, not a warning.is_safe => html or wrap raw are injection points. This needs line-by-line review before anything reaches a template rendering user input.Key questions.
ServiceProvider/composer.json extra.laravel, or only a Symfony Bundle?is_safe, and do any accept user-controlled input?twig/extensions, and if so, at what upstream commit?Stack fit. Target is PHP 8.x / Laravel 10–11 / Twig 3.x via twigbridge. Verify the bridge's Laravel support before anything else — this is the actual gate, not this package. If the bridge does not support the target Laravel major, the package is moot. If you are not already committed to Twig, the cheaper path is to port the handful of filters you need into Blade directives or a small helpers.php; that removes both the bridge and this dependency.
Migration path. Treat this as greenfield and scope it as a vertical slice, not a platform change. Do not convert existing Blade views. Pick one rendering surface (transactional email, PDF generation, or a single admin module), prove Twig + bridge + extension there, and stop. A second templating language is a permanent cognitive tax on the team; it needs a stronger justification than "these filters are handy."
Compatibility.
twig/twig:^3.x and read the package's composer.json constraints directly; run composer why-not twig/twig <version> to see the real conflict.Sequencing.
twigbridge supports the target Laravel; if not, stop.is_safe and any input-facing filter.NOTICE, and document the patch policy.Recommendation. Do not take this as a runtime dependency. Either reimplement the specific filters internally, or fork and own them. The package is small enough that its value is in the code, not in the release stream — and there is no release stream to speak of.
Maintenance. Effectively you own it from day one. Upstream has no dependents and near-zero community signal, so plan for a fork with a documented patch policy and an owner. The recurring cost is Twig major upgrades (Twig 4 will land eventually) and the associated re-validation of every custom filter's behavior and safety flags.
Support. No vendor, no SLA, no CVE feed. Internal escalation only. Bus factor is one unless the fork is documented and reviewed by a second engineer. Budget a named owner for the Twig bridge and the extension fork together — they fail as a unit.
Scaling. Rendering throughput is not the concern; custom filters are cheap. The real scaling cost is the compiled-template cache: Twig writes to its own cache directory while Laravel writes to storage/framework/views, so you now have two cache lifecycles, two warm-up paths, and a multi-node invalidation problem on deploy. Standardize the Twig cache path on shared storage or a warm-on-deploy step, or you will get stale-template incidents that look like random 500s.
Failure modes.
is_safe => html filter applied to user data. This is the one that becomes a security incident.twigbridge falls behind a Laravel upgrade and blocks the platform upgrade — a scheduling risk, not a runtime one.Ramp-up. A developer fluent in Twig needs half a day to wire the bridge and register the extension; a Blade-only team needs one to two days to become productive in Twig, plus ongoing context-switching cost across two template languages. That cognitive tax is the strongest argument against adoption and should be weighed explicitly against the handful of filters actually gained.
How can I help you explore Laravel packages today?