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 Template Event Bundle

Twig Template Event Bundle Laravel Package

shapecode/twig-template-event-bundle

A Symfony bundle that adds event dispatching around Twig template rendering, letting services hook into template resolution and output without modifying individual templates.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Twig Template Event Bundle
Is shapecode/twig-template-event-bundle a Laravel package?
No. It is a Symfony bundle that hooks into Twig's template lifecycle and dispatches Symfony events so listeners can observe or mutate rendering. Laravel's native view layer is Blade, with different contracts and conventions. Treat this as a Symfony package, not a Laravel dependency.
Can I install shapecode/twig-template-event-bundle in Laravel with Composer?
You can run Composer require, but nothing will auto-register in Laravel because the package assumes Symfony's kernel and bundle registration model. It will also pull Symfony components into an app that already ships its own equivalents. Plan for manual service provider wiring and dispatcher reconciliation before expecting it to work.
How do I use this bundle with Laravel and Twig?
You need a Twig bridge for Laravel, such as rcrowe/twigbridge or its current equivalent, and you must confirm Twig can render a representative view first. Then register the bundle's listeners explicitly against Laravel's container and map Symfony EventDispatcherInterface calls onto Laravel's dispatcher or a scoped Symfony dispatcher. Validate that the events actually fire under the bridge.
Which Laravel and PHP versions are supported?
The package is built for Symfony and Twig version constraints, not Laravel versions, so Laravel compatibility is not guaranteed by the package itself. Check the repository's composer.json for PHP and Symfony component constraints before installing. In Laravel, Symfony component version pins can collide during framework upgrades.
What does this bundle do around Twig template rendering?
It dispatches events around Twig template resolution and rendering so services can hook in without editing individual templates. Listeners can observe or mutate the rendering flow, which is useful for instrumentation, context injection, caching, or debugging. Check the README for the exact event names and listener contracts.
Does shapecode/twig-template-event-bundle work with Blade?
No. The package hooks Twig's lifecycle and Symfony's event system, while Blade uses its own compiler, view composers, and Laravel events. If Blade is acceptable for your application, this package is unnecessary. Use native Laravel view features instead.
What are Laravel alternatives to this package for hooking view rendering?
Use view composers for context injection, Blade directives for template-level helpers, and Laravel events or middleware for render instrumentation and logging. These cover most use cases such as timing, logging, and cache invalidation with zero third-party surface area. The valuable idea to borrow is dispatching events around rendering, which Laravel can express natively.
Is this package safe and maintained for production use?
It has very low adoption, a small star count, and a single-maintainer profile, so bus factor and long-term maintenance are the dominant risks. Code quality is less of a concern than abandonment and version lag against Twig and Symfony releases. Only adopt it if Twig is already mandated, and be prepared to vendor or fork it.
How do I test that Twig template events fire in a Laravel app?
Render a representative Twig view through the bridge and assert that your registered listener is invoked and receives the expected template context. The bridge, not the bundle, is the most likely failure point, so test event dispatch end to end. Use Laravel's testing tools to fake or spy on the dispatcher where possible.
How do I migrate from Symfony Twig template events to native Laravel?
Do not install the bundle if Blade is acceptable. Reimplement only the hooks you need with a Laravel view composer plus a ViewRendered-style event or middleware. This removes the dependency, avoids Symfony component conflicts, and keeps the codebase idiomatic for Laravel developers.
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.
dbravoan/dbcms-admin-theme-dbcms
dbravoan/dbcms-theme-db-cyber
dbravoan/dbcms-blocks-basic
dbravoan/dbcms-module-content-audit
dbravoan/dbcms-module-ai-assistant
paygate-to/paygate-php
padosoft/askmydocs-connector-base
defstudio/supercharged-carbon
bernskioldmedia/laravel-matomo
bernskioldmedia/laravel-harvest
bernskiold/laravel-data-scrubber
bernskiold/laravel-currency-converter
bernskiold/laravel-campaign-monitor
bernskioldmedia/laravel-autotranslate
siberfx/telegram-bot
roy-sandip/laravel-view-extended
gregsphotography/site-builder-core
roy-sandip/laravel-view
anodyne/blade-fluentui-icons
webx-ui/module-catalog-collections