symfony/ux-twig-component
Symfony UX Twig Components lets you bind PHP objects to Twig templates to build reusable UI pieces like alerts, modals, and sidebars. Create small, composable components with clean rendering and better template organization for Symfony apps.
<twig:ComponentName>) reduce ad-hoc solutions.attributes.defaults(stimulus_controller()).provide/inject for state management in nested components (e.g., multi-step forms) to eliminate prop drilling.PostMountEvent/PostRenderEvent for lazy-loading or analytics hooks.debug:twig-component command and profiler integration (e.g., profiler.collect_components) simplify troubleshooting.RenderedComponent::crawler()).AsTwigComponent attribute replaces ComponentInterface).Adopt if:
PreMount, PostRender) for side effects.Look elsewhere if:
For Executives:
"This package lets us build modular, reusable UI components in Twig—like Lego blocks for our web app—without sacrificing performance or developer speed. It’s part of Symfony’s official ecosystem, so it’s stable and backed by the same team that powers Symfony’s core. For example, we could replace 50 lines of spaghetti Twig includes with a single alert component that’s easy to update and reuse across dashboards, forms, and error pages. It also plays nicely with our real-time features (e.g., live updates via Mercure), so we’re not betting on a single tech stack. The trade-off? A small upfront investment to adopt it, but long-term savings in maintenance and developer ramp-up time."
For Engineers: *"This is Symfony’s battle-tested way to do Twig components—think React’s components but for server-rendered Twig. Key wins:
provide/inject to pass state down nested components.attributes.defaults(stimulus_controller()).debug:twig-component command and profiler integration.How can I help you explore Laravel packages today?