Weave Code
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
Stimulus Bundle

Stimulus Bundle Laravel Package

symfony/stimulus-bundle

Symfony bundle that integrates Stimulus with Symfony and Symfony UX. Adds Twig stimulus_* helpers for controllers/actions/targets, supports AssetMapper, and provides a service to build Stimulus data attributes for use in templates and services.

View on GitHub
Deep Wiki
Context7

Integration with your Symfony app & Stimulus!

Frequently asked questions about Stimulus Bundle
Can I use StimulusBundle in Laravel? If so, how does it integrate with Symfony UX components like Turbo or Mercure?
StimulusBundle is designed for Symfony, not Laravel, but you can use it in Laravel by leveraging Symfony’s UX components via the Symfony UX bundle. For Turbo or Mercure, ensure your Laravel app integrates Symfony’s UX components (e.g., via a micro-frontend or shared frontend layer). StimulusBundle’s Twig helpers and AssetMapper support will work if your frontend pipeline aligns with Symfony’s ecosystem.
What’s the minimal Laravel setup required to use StimulusBundle?
StimulusBundle isn’t natively Laravel-compatible, but you can adopt it by integrating Symfony’s UX bundle or using a shared frontend layer (e.g., Vite/Encore). Ensure your Laravel app supports Symfony’s AssetMapper (v6.4+) or Webpack Encore for asset compilation. Twig is mandatory for the `stimulus_*` helpers, so you’ll need a Twig-compatible setup (e.g., via Symfony’s TwigBridge or a custom integration).
How do I migrate from jQuery plugins to Stimulus controllers using StimulusBundle?
Replace jQuery plugins with Stimulus controllers by first identifying interactive elements in your Twig templates. Use `{{ stimulus_controller('controller-name') }}` to attach controllers, then refactor jQuery logic into Stimulus actions (e.g., `connect()`, `toggle()`). StimulusBundle’s Twig helpers reduce boilerplate, and you can phase adoption by starting with simple interactions like modals or tooltips before tackling complex UIs.
Does StimulusBundle work with Laravel Mix or Vite? What about Webpack Encore?
StimulusBundle is optimized for Symfony’s AssetMapper (v6.4+) or Webpack Encore, not Laravel Mix or Vite directly. For Vite, you’ll need to configure it to work with Symfony’s UX bundle or use a hybrid setup where Stimulus controllers are compiled via Vite but integrated via Symfony’s Twig helpers. Webpack Encore is supported but may require manual adjustments (e.g., enabling ES Modules for Stimulus controllers).
What Laravel versions and PHP versions does StimulusBundle support?
StimulusBundle itself doesn’t support Laravel directly, but its underlying Symfony dependencies require PHP 8.1+ (v2.x) or PHP 8.4+ (v3.0.0). For Laravel integration, ensure your Symfony UX or frontend layer meets these PHP requirements. Laravel 10+ works best with Symfony 6.4+/7.4+, which aligns with StimulusBundle’s supported versions. Always check the Symfony UX bundle’s compatibility for your Laravel version.
How do I debug Stimulus controllers in a Symfony/Laravel hybrid app?
Use Symfony’s Profiler to inspect Stimulus actions and data attributes, then fall back to browser DevTools for frontend debugging. StimulusBundle logs errors via Symfony’s error handler if configured. For complex issues, check the `data-controller` and `data-action` attributes in Twig templates, and verify your AssetMapper or Webpack Encore setup isn’t blocking Stimulus JS files. Enable debug mode in Symfony (`APP_DEBUG=1`) for detailed logs.
Can I use StimulusBundle with TypeScript? What about Alpine.js?
Yes, StimulusBundle supports TypeScript controllers if your build tool (e.g., Webpack Encore or Vite) is configured for TypeScript. For Alpine.js, StimulusBundle isn’t a direct replacement, but you can use both in a hybrid setup—Stimulus for complex interactions and Alpine for simpler DOM manipulations. StimulusBundle’s Twig helpers won’t interfere with Alpine, but you’ll need to manage dependencies separately.
What are the performance implications of using StimulusBundle in a Laravel app?
StimulusBundle adds minimal overhead if used judiciously. The main performance impact comes from AssetMapper or Webpack Encore processing Stimulus JS files. Avoid overusing controllers/actions in performance-critical loops (e.g., rendering large lists). Test with tools like Lighthouse or Symfony’s Profiler to measure runtime impact. For heavy jQuery replacements, Stimulus often reduces bundle size and improves interactivity without full SPA overhead.
How do I generate Stimulus data attributes dynamically from Laravel services?
StimulusBundle provides a `stimulus_helper` service to generate data attributes from PHP services. Inject the service into your Twig templates or controllers, then use methods like `generateController()` or `generateAction()` to create dynamic attributes. For example, pass a Laravel model’s ID to the service to auto-generate `data-controller` or `data-action` values tied to backend logic. This is ideal for real-time dashboards or dynamic forms.
Are there alternatives to StimulusBundle for Laravel that offer similar functionality?
For Laravel, consider standalone Stimulus.js with Laravel Mix/Vite (no Symfony dependency) or Laravel-specific packages like `laravel-stimulus`. For Symfony-like Twig integration, explore `spatie/laravel-twig` to bridge Twig with Laravel, then manually integrate Stimulus. If you need Symfony UX features (Turbo/Mercure), StimulusBundle is the closest fit, but it requires adopting Symfony’s ecosystem. Alpine.js or Livewire are lighter alternatives for simpler interactivity.
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.
codraw/entity-migrator
codraw/doctrine-extra
codraw/aws-tool-kit
codraw/validator
codraw/workflow
codraw/open-api
codraw/cron-job
codraw/process
codraw/log
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony