- Is symfony/stimulus-bundle a Laravel package?
- No. symfony/stimulus-bundle is a Symfony bundle that integrates Stimulus with Symfony, Twig and Symfony UX. It is not designed for Laravel, and Laravel developers typically use Livewire, Alpine.js or standalone Stimulus instead. If you are evaluating it for a Laravel app, treat it as a Symfony-only dependency unless you are building a separate Symfony service.
- How do I install symfony/stimulus-bundle?
- Install it with Composer using composer require symfony/stimulus-bundle. Symfony Flex usually registers the bundle automatically, but you should confirm it is enabled in config/bundles.php. You also need AssetMapper configured, then you can place Stimulus controllers in assets/controllers and reference them from Twig with the stimulus_* helpers.
- Which Symfony and PHP versions does StimulusBundle support?
- Version 3.0.0 requires Symfony 7.4+ and PHP 8.4+. The 2.x line, such as v2.34.0, supports Symfony 6.4+ and PHP 8.1+. Audit your Symfony and PHP versions before upgrading, because the major version jump changes platform requirements.
- Do I need AssetMapper to use StimulusBundle?
- AssetMapper is the recommended and required path for StimulusBundle v3.0.0+, and it integrates cleanly with Symfony UX. Webpack Encore is supported but may require manual tweaks, including ES Modules support for Stimulus controllers. If you use AssetMapper, configure excluded_patterns in config/packages/asset_mapper.yaml to avoid conflicts with existing assets.
- What are the Twig stimulus_* helpers and how do I use them?
- The bundle provides Twig functions and filters such as stimulus_controller, stimulus_action and stimulus_target. They generate the correct data-controller, data-action and data-*-target attributes directly in your templates. For example, you can attach a controller with a Twig call on an element instead of writing manual data attributes. This keeps Stimulus wiring declarative and reduces boilerplate in Twig templates.
- Does StimulusBundle work with Symfony UX Turbo, Mercure and Dropzone?
- Yes. StimulusBundle is built as part of the Symfony UX ecosystem and integrates with Turbo, Mercure and Dropzone. Stimulus controllers can reconnect correctly during Turbo navigation when written with proper lifecycle handling. This lets you add SPA-like navigation, real-time updates and file uploads without leaving Symfony's frontend conventions.
- Can I build Stimulus data attributes from a PHP service?
- Yes. The bundle includes a helper service that builds Stimulus data attributes so you can use them in templates and PHP services. This is useful for dynamic UIs such as dashboards where controller names, actions or target values are computed on the backend. Inject the service and pass the generated attributes into Twig or another service instead of hardcoding JavaScript.
- How do I test Stimulus controllers in a Symfony application?
- Unit test the controller logic with a JavaScript test runner such as Jest or Vitest, and test rendered attributes with Symfony's WebTestCase or Panther for browser behavior. In Twig tests, assert that stimulus_controller and stimulus_action output the expected data attributes. For debugging, combine the Symfony Profiler with browser DevTools to inspect Stimulus actions and targets.
- What are alternatives to symfony/stimulus-bundle?
- Alternatives include standalone Stimulus without Symfony integration, Alpine.js for simpler interactive UI needs, and manual Webpack Encore setup for Stimulus. Laravel teams usually evaluate Livewire or Alpine.js instead because this bundle is Symfony-specific. Choose StimulusBundle when you are committed to Symfony UX, Twig and AssetMapper.
- Is StimulusBundle actively maintained and safe for production?
- Yes. It is maintained as part of Symfony UX and follows Symfony's release and versioning conventions. For production, verify your asset pipeline supports ES Modules, measure bundle size when replacing jQuery plugins, and refactor inline onclick handlers into stimulus_* attributes. Test with excluded_patterns in AssetMapper and confirm your Symfony and PHP versions match the bundle release you adopt.