Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Extra Bundle Laravel Package

twig/extra-bundle

Twig Extra Bundle is a Symfony bundle that automatically enables all Twig extra extensions with no configuration. Install via Composer to add useful filters, functions, and tags to your Twig templates without manual setup.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit The twig/extra-bundle is a Symfony bundle first and a Twig convenience second. Its headline value — "use all extra extensions without any configuration" — is delivered entirely through Symfony's bundle registration, dependency-injection container, and kernel boot sequence. In a Laravel application those mechanisms do not exist, so the single feature the package markets is precisely the feature that does not transfer. What does transfer is the underlying set of extension classes (StringExtension, TextExtension, ArrayExtension, MarkdownExtension, CssInlinerExtension), and those are shipped in standalone twig/*-extra packages that can be registered by hand with no Symfony kernel at all. From a TPM standpoint this reframes the decision: we are not evaluating "adopt this bundle," we are evaluating "adopt Twig extra extensions," and the bundle is an optional delivery mechanism we would likely bypass.

The second architectural consideration is the extension split. Roughly half the extensions have genuine Symfony coupling — FormExtension (FormFactory), UrlExtension/WebExtension (RouterInterface, RequestStack), CsrfExtension (CsrfTokenManager), AssetExtension (AssetMapper), TranslationExtension (Symfony translator). In Laravel these require adapter layers mapped onto Illuminate\Routing\Router, Illuminate\Http\Request, Illuminate\Contracts\Translation\Translator, and Laravel's CSRF middleware. Each adapter is bespoke code we own forever. The remaining extensions are pure PHP and carry near-zero integration cost.

Integration feasibility Feasible but conditional, and the effort is dominated by things the bundle does not do for us. Concretely: (1) Composer resolution — the bundle pulls symfony/* constraints that must coexist with Laravel's own pins; (2) a Laravel service provider to instantiate a Twig\Environment (via twig-laravel/twig or a custom adapter) and register a hand-picked extension list; (3) explicit exclusion of Symfony-dependent extensions to prevent container-boot failures; (4) a decision on whether Blade remains the default engine. Items (2) and (3) are the actual work; the composer require line in the README is the smallest part.

Technical risk

  • Dependency coupling — high. The bundle's constraints move with Symfony and Twig majors. v4.0.0-alpha1 already signals a PHP 8.2 baseline and return-type changes. Every Laravel or Twig upgrade becomes a regression-test event on the templating layer.
  • Ownership risk — high. The upstream is well-maintained by Twig core maintainers, but there is no Laravel-side contract. Our service provider and any Symfony-service shims become internal, undocumented, single-owner code.
  • Dual-engine risk — medium. Running Blade and Twig side by side splits CSRF handling, asset paths, escaping conventions, and developer mental models. This is a long-tail productivity tax rather than a project risk, and it compounds silently.
  • Runtime/performance risk — low. Pure extensions are negligible. Full adoption adds unused Symfony services to the container, which is waste, not danger.
  • Ecosystem signal — weak. dependents: 0 and a mid-20s overall score with a 58 opportunity score indicates an unproven fit for our context. We would be pathfinding, and should price the spike accordingly.

Key questions

  1. Is Twig a strategic commitment or a tactical workaround? If tactical, the answer is "register three pure extensions manually, skip the bundle."
  2. Which extensions are genuinely required? If the list is String/Text/Array, we can satisfy it without this package.
  3. Are Form, CSRF, URL, or Asset extensions in scope? If yes, we are also committing to an adapter layer and its maintenance budget — that needs a named owner and a sized estimate.
  4. Who owns upgrades, and what is our acceptable lag behind Twig majors?
  5. What is the rollback? If the spike fails, do we return to Blade cleanly, or is template syntax already spread across the codebase?
  6. Do we have any Symfony component adoption (Forms, Security, API Platform) on the roadmap that would legitimise the coupling?

Integration Approach

Stack fit Poor as-is; workable only in a narrow configuration. Good fit: hybrid monorepos where a Symfony application already exists and Laravel is a frontend — the bundle earns its keep in the Symfony half. Conditional fit: Laravel projects that already run twig-laravel/twig and need only pure extensions. Non-fit: Blade/Livewire/Inertia stacks, teams without Twig exposure, or any project where the templating layer is not a stated architectural concern.

Migration path Adopt in slices, with a kill switch at each gate.

  • Gate 0 — Spike (1–2 weeks). Install the standalone twig/string-extra, twig/intl-extra, twig/markdown-extra, twig/cssinliner-extra packages only. Register them in a small Laravel service provider. Measure: does Composer resolve cleanly against our locked Laravel/Symfony constraints, and does a representative template render? Do not install twig/extra-bundle yet.
  • Gate 1 — Non-Symfony extensions in production. Ship on one bounded surface (an admin view or a templated email), with Blade still the default engine.
  • Gate 2 — Symfony-coupled extensions. Only if a concrete feature demands it. Build the adapter behind an interface so it can be swapped, and time-box it.
  • Gate 3 — Adopt the bundle proper. Only justified if we also adopt a Symfony kernel or the bundle's auto-registration saves measurable work. In most Laravel scenarios it will not, and the correct outcome is to stop at Gate 1.

Compatibility Verify the PHP floor (v3 line supports older runtimes; v4 targets PHP 8.2+), the Twig major (3.x), and Symfony component ranges against the application's existing composer.lock. Pay explicit attention to symfony/translation, symfony/routing, and symfony/form if Laravel is pinned to a different major. Build a CI matrix across our supported PHP and Laravel versions before Gate 1, not after.

Sequencing

  1. Confirm the extension shortlist with engineering. 2. Resolve dependencies in isolation on a branch. 3. Register extensions manually via a service provider; exclude all Symfony-coupled extensions. 4. Add golden-template tests covering escaping, translation, and date formatting. 5. Pilot on one surface. 6. Re-evaluate the bundle itself only after the pilot succeeds. 7. Publish an internal decision record stating why the bundle was or was not adopted — this prevents the argument recurring in six months.

Operational Impact

Maintenance Recurring cost is dominated by the integration shim, not the upstream package. Budget a standing allocation for upgrade verification each time Laravel, Twig, or a Symfony component bumps a major. If we skip the bundle and use only standalone twig/*-extra packages, that cost roughly halves — fewer constraints, fewer transitive Symfony services, smaller blast radius.

Support MIT licence, no commercial backing, no SLA. Upstream responsiveness is good (the release notes show active bug-fixing on cache-pool wrapping and extension registration), but there is no Laravel-specific support path. We need an internal runbook covering: how extensions are registered, which are intentionally excluded and why, and how to diagnose a container-boot failure caused by a stray Symfony-dependent extension. That runbook is the single highest-value operational artefact for this decision.

Scaling Technically a non-issue: extension registration is a boot-time concern and pure-PHP filters add no meaningful overhead. The real scaling constraint is organisational — every additional team touching templates must learn Twig alongside Blade. Beyond two or three teams, dual-engine drift becomes a governance problem requiring linting, shared partials, and an explicit style guide.

Failure modes

  • Boot failure. An auto-registered Symfony-dependent extension resolves a missing service and the container fails. Mitigate with an explicit allowlist, never a denylist.
  • Composer deadlock. A Laravel or Twig upgrade conflicts with a pinned symfony/* constraint; resolution requires --with-all-dependencies and manual untangling.
  • Silent divergence. Form rendering, CSRF tokens, or URL generation behave differently between Blade and Twig, producing bugs that only appear on one surface.
  • Shim rot. An adapter written against an internal Symfony interface breaks on upgrade with no test coverage.
  • Template drift after rollback. If adoption is reversed, converted templates have no path back to Blade; migration must be reversible or clearly one-way with sign-off.
  • Single-owner dependency. The engineer who wrote the service provider leaves; nobody can safely upgrade the stack.

Ramp-up Twig syntax is learnable in days; the costly part is Twig-plus-Symfony semantics — extension points, escaping and autoescape behaviour, and the service-container assumptions behind the coupled extensions. Estimate one to two weeks for a Laravel developer to become productive, and considerably more for anyone expected to maintain form or routing adapters. Plan for a paired onboarding on the first converted surface and treat the initial template conversion as a training exercise with a deliberately small scope.

TPM recommendation Treat this as a conditional, low-priority opportunity rather than an adoption. Confirm the extension shortlist first; if it contains no Symfony-coupled extensions, take the standalone twig/*-extra packages and leave twig/extra-bundle out of the dependency graph. Escalate to a full adoption decision only when Symfony components enter the Laravel roadmap, at which point the bundle's auto-configuration finally earns its cost.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels