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
Twig Extra Bundle

Twig Extra Bundle Laravel Package

softspring/twig-extra-bundle

Softspring Twig Extra Bundle adds handy Twig extensions, filters, and functions to Symfony applications, helping simplify template logic and common view helpers. It integrates cleanly with Twig and Symfony for more concise, reusable templates.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Twig Extra Bundle
What does softspring/twig-extra-bundle actually do?
It is a Symfony bundle that ships a set of Twig extensions, filters, and functions aimed at simplifying common template logic and view helpers. Instead of repeating the same Twig snippets or writing custom extensions in every project, you register the bundle once and reuse its helpers across templates. The stated goal is more concise and reusable Twig templates that integrate cleanly with Symfony's Twig integration.
Is softspring/twig-extra-bundle compatible with Laravel?
No. It is a Symfony bundle that depends on Symfony's Twig integration and the bundle registration mechanism, while Laravel's default templating engine is Blade. Laravel developers evaluating it should treat it as a reference or only use it in projects where Twig is wired into the framework manually. If you need Twig inside Laravel, look at Twig bridge packages rather than Symfony bundles.
How do I install softspring/twig-extra-bundle with Composer?
Install it with Composer using the package name softspring/twig-extra-bundle, typically as a normal require since you will need it at runtime. Composer resolves the matching version against your installed Symfony and Twig constraints, so review the output for conflicts before committing the lock file. After installation, the bundle must still be registered in your kernel or bundles config to take effect.
How do I enable the bundle in a Symfony application?
With Symfony Flex the bundle is usually enabled automatically through the generated config/bundles.php entry. In a manual setup you add the bundle class to the bundles array in config/bundles.php for the environments where you want it active. Once registered, its Twig extensions are picked up by the Twig environment and become available in your templates.
Which Twig filters and functions does this bundle add?
The package provides a collection of extra filters, functions, and extensions intended as everyday view helpers, but the exact list is version dependent. Check the repository README and the extension classes under the source directory for the authoritative names and signatures before relying on them. Because helper names are not part of Twig core, pinning a version avoids surprises when the set changes.
Which Symfony, PHP, and Twig versions are supported?
Support depends on the release you install, so read the require and require-dev sections of the package's composer.json for the definitive constraints. Older tagged versions typically target older Symfony and PHP lines, while newer tags move forward with maintained versions. Always run composer update in a branch and let the resolver confirm compatibility with your application's existing dependencies.
Can I use it with standalone Twig without Symfony?
Not directly, because the distribution is packaged as a Symfony bundle and its service wiring assumes a Symfony container and kernel. For plain Twig projects you would need to instantiate the extension classes yourself or extract the logic into your own TwigExtension. In that case, a small custom extension is usually simpler than pulling in the whole bundle.
Does softspring/twig-extra-bundle hurt template rendering performance in production?
Twig extensions are registered once per environment and compiled into cached templates, so the runtime cost is comparable to any other extension. The main thing to watch is any helper that performs heavy work such as I/O or repeated object hydration inside a loop. Keep the Twig cache enabled in production and profile templates that call the helpers frequently.
How do I test templates that rely on these Twig extensions?
Enable the bundle in your test kernel configuration so the extensions are present when templates render, then assert on rendered output in functional tests. For isolated unit tests of a single filter or function, instantiate the extension class directly and call its callable rather than booting the whole kernel. Snapshot-testing key templates helps catch behaviour changes when you upgrade the bundle.
What are the alternatives, and is this package actively maintained?
Alternatives include Twig's built-in filters, the official twig/extra-bundle for extra filters and functions, and simply writing your own small Twig extension for project-specific helpers. Before adopting it, check the GitHub repository for recent commits, tagged releases, and open issues, since a small bundle's maintenance cadence matters for upgrade planning. If activity looks sparse, copying the few helpers you need into your own codebase removes the dependency risk.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console