symfony/stimulus-bundle
Symfony bundle that integrates Hotwired Stimulus into your app, wiring up controllers, auto-loading, and UX bridges with Symfony tooling. Ideal for adding modest JavaScript behavior to Twig and Symfony UX components without a heavy frontend setup.
This package is Symfony-specific and cannot be used in Laravel. For Laravel projects requiring Stimulus integration, avoid this bundle entirely—instead, install Stimulus manually via npm/yarn (e.g., npm install stimulus) and configure it within Laravel Mix or AssetMapper. Start with a minimal resources/js/controllers/index.js that imports Stimulus and registers controllers from resources/js/controllers/. Use Blade directives to include compiled JS/CSS via mix() or asset(). No Composer package or Symfony-style auto-registration is needed—just follow standard Laravel frontend conventions.
In Laravel, manage Stimulus controllers as standard NPM modules under resources/js/controllers/, exporting default classes that extend Stimulus.Controller. Register them explicitly in index.js (e.g., application.register('hello', HelloController)). Wire behavior using Blade’s @props, {{ }}, or Blade directives to inject data-* attributes into HTML (e.g., <div data-controller="hello" data-hello-target="name">). Use data-action and data-target as usual. For reusable logic, create shared controller base classes or use helper modules (e.g., mixins/toggle.js). When integrating with Laravel Form components, extend form macros to inject data-controller attributes via attributes->merge().
Do not confuse this bundle with Laravel-native solutions—there is no Symfony-style stimulus.json manifest in Laravel. Manual controller registration is required; Stimulus won’t auto-discover files unless you use a bundler plugin like stimulus-fetch or custom Webpack glob imports. Ensure your webpack.mix.js (or Vite config) includes Stimulus polyfills and exports correctly. Common pitfalls: forgetting to npm run build after adding new controllers, case mismatches in controller names (e.g., HelloController vs hello_controller), and missing application.stimulus.js registration in Blade. Debug using browser console warnings for unregistered controllers and verify mix-manifest.json includes your JS entrypoint. For performance, consider lazy-loading controllers using dynamic import() and application.load() with URL-based activation.
How can I help you explore Laravel packages today?