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

Stimulus Bundle Laravel Package

symfony/stimulus-bundle

Integrates Symfony, Stimulus, and Symfony UX: Twig stimulus_* functions and filters add controllers, actions, and targets to templates, with AssetMapper support and a helper service for building Stimulus data attributes in your services.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Symfony UX Modernization Roadmap Adopt StimulusBundle as the cornerstone for Symfony UX integration, enabling teams to replace legacy jQuery or vanilla JS with modular, maintainable Stimulus controllers while leveraging Symfony’s ecosystem (Turbo, Mercure, AssetMapper). Aligns with Symfony’s long-term strategy to reduce frontend complexity without sacrificing interactivity.

  • Progressive Frontend Enhancement Enable incremental adoption of modern frontend patterns:

    • Replace static forms with dynamic Stimulus-driven interactions (e.g., real-time validation, collapsible sections).
    • Introduce Turbo-powered navigation for SPA-like behavior without a full rewrite.
    • Use Mercure for real-time updates (e.g., notifications, live dashboards) without WebSocket boilerplate. Justification: Avoids the risk of big-bang frontend migrations while delivering tangible UX improvements.
  • Build vs. Buy: "Buy" Decision Use StimulusBundle to avoid reinventing:

    • Twig-Stimulus integration (e.g., stimulus_controller() functions).
    • Asset pipeline compatibility (AssetMapper/Webpack Encore), with version constraints to verify.
    • Stimulus controller discovery and loading. Only "build"* if requiring deep customization (e.g., hybrid Stimulus/React setups or non-Symfony backends).
  • Cost Optimization for Legacy Systems Modernize old Symfony apps (pre-4.0) with Stimulus instead of:

    • Full frontend framework adoption (React/Vue).
    • Costly backend refactors or microservice splits. Example: Replace jQuery-based admin panels with Stimulus + Turbo for a 30% faster dev cycle.
  • Cross-Team Collaboration Unify backend (PHP) and frontend (JS) teams under a shared tooling stack:

    • Stimulus controllers live alongside PHP services, reducing context-switching.
    • Twig templates remain the single source of truth for frontend logic. Outcome: Faster onboarding for backend devs contributing to frontend features.
  • Release Note Impact: v3.6.0 No major feature shift. The release is a maintenance update: tooling dependency refresh, improved debug:autowiring type documentation, and a compatibility guard. The notable product/planning impact is the explicit conflict with symfony/asset-mapper 8.2 and later in v3.6.0. Teams on current supported Symfony stacks are unaffected, but roadmap planning should confirm AssetMapper version alignment before adoption or upgrade.


When to Consider This Package

Adopt StimulusBundle If:

  • Your Symfony app (6.3+) needs interactive UIs but lacks complex state management (e.g., admin panels, forms, tooltips).
  • You prioritize performance (Stimulus is ~10KB vs. 100KB+ for React/Vue) and maintainability (modular JS).
  • Your roadmap includes Symfony UX (Turbo, Mercure, Dropzone) and you want seamless integration.
  • You’re replacing jQuery/vanilla JS and want a Twig-native solution (e.g., {{ stimulus_controller('example') }}).
  • Your team is small or PHP-heavy and prefers convention-over-configuration for frontend logic.
  • You need real-time features (Mercure) or SPA-like navigation (Turbo) without full framework overhead.
  • Your legacy app requires modernization but can’t justify a full rewrite.
  • You can pin dependency versions to a supported combination. With v3.6.0, verify that symfony/asset-mapper is not 8.2+ unless a newer StimulusBundle release explicitly restores compatibility.

Look Elsewhere If:

  • You’re fully committed to React/Vue/Angular and need deep integration with those ecosystems (e.g., shared state, component libraries).
  • Your app requires complex state management (e.g., global app state, Redux-like patterns) beyond Stimulus’s scope.
  • You don’t use Symfony (StimulusBundle is Symfony-specific; use standalone Stimulus for other backends).
  • Your team lacks PHP/Twig expertise (StimulusBundle tightens coupling to Symfony’s templating system).
  • You need real-time features beyond Mercure (e.g., custom WebSocket integrations or advanced pub/sub).
  • Your frontend stack relies on non-Symfony tools (e.g., Laravel Mix, Vite, or custom Webpack setups with minimal Twig).
  • You’re building a public-facing SPA where SEO or framework-specific tooling (e.g., Next.js) is critical.
  • You require symfony/asset-mapper 8.2+ today and cannot wait for a newer StimulusBundle release or adjust dependency constraints.

How to Pitch It (Stakeholders)

For Executives:

"StimulusBundle lets us deliver modern user experiences faster and cheaper by leveraging Symfony’s existing stack—without the complexity or cost of heavy JavaScript frameworks like React or Vue.

The Problem: Our current frontend (jQuery/vanilla JS) is slow to maintain, hard to scale, and misses modern UX opportunities like real-time updates or smooth navigation.

The Solution: StimulusBundle integrates Stimulus.js—a lightweight, modular JavaScript library—directly into Symfony. It lets us:

  • Replace outdated widgets (e.g., modals, tooltips) with modern, maintainable Stimulus controllers.
  • Add real-time features (e.g., live dashboards) using Mercure, without custom WebSocket code.
  • Enable SPA-like navigation with Turbo, reducing page load times by 40%.
  • Keep development costs low by using our existing PHP/Symfony teams—no need for specialized frontend engineers.

Why Now?

  • Low Risk: Start with small features (e.g., dynamic forms) and scale as needed.
  • Future-Proof: Aligns with Symfony’s roadmap, avoiding tech debt from proprietary solutions.
  • Dependency Guard: v3.6.0 explicitly flags a conflict with symfony/asset-mapper 8.2+. We should confirm our AssetMapper version during pilot scoping; this is a manageable dependency constraint, not a product blocker for current supported stacks.
  • Measurable ROI: Faster development cycles, happier users, and reduced maintenance costs.

Ask: Approve a 6-month pilot to modernize 2–3 high-impact features (e.g., admin panel, checkout flow) using StimulusBundle. Budget: $50K (mostly developer time, minimal third-party costs)."


For Engineering Teams:

"StimulusBundle is the fastest, lowest-effort way to add modern interactivity to Symfony apps. Here’s why it’s a no-brainer—with one dependency caveat to check:

What It Solves:

  • No More Manual JS Integration: Automatically generates Stimulus data attributes in Twig (e.g., {{ stimulus_controller('example') }}).
  • Seamless Symfony UX Integration: Works out-of-the-box with Turbo (navigation), Mercure (real-time), and AssetMapper (assets) on supported version combinations.
  • Modular JavaScript: Stimulus controllers are small, reusable, and easy to debug compared to monolithic frameworks.
  • Progressive Adoption: Start with simple interactions (e.g., modals) and scale to complex UX as needed.

How to Get Started:

  1. Install the bundle:
    composer require symfony/stimulus-bundle
    
  2. Use Twig functions in templates:
    {{ stimulus_controller('example') }}
    {{ stimulus_action('example#action', { param: 'value' }) }}
    
  3. Write Stimulus controllers in JavaScript (or TypeScript) and let the bundle handle the rest.

Key Advantages Over Alternatives:

Feature StimulusBundle Standalone Stimulus React/Vue
Symfony Integration ✅ (Twig, UX) ❌ (Manual setup) ❌
Asset Pipeline ✅ (AssetMapper; check version constraints) ❌ ❌
Learning Curve Low Medium High
Bundle Size ~10KB ~10KB 100KB+
Long-Term Support ✅ (Symfony) ❌ ✅

v3.6.0 Dependency Note:

  • The release adds a conflict with symfony/asset-mapper 8.2 and later. If your app is pinned to AssetMapper 8.2+, either adjust to a compatible AssetMapper version or wait for a newer StimulusBundle release.
  • Other changes are low-risk: tooling dependency updates and improved debug:autowiring documentation.

Migration Path:

  1. Phase 1: Replace simple JS behaviors (e.g., tooltips, modals) with Stimulus.
  2. Phase 2: Migrate asset pipeline to AssetMapper (if not already using it), confirming StimulusBundle compatibility with your AssetMapper version.
  3. Phase 3: Integrate with Turbo for navigation or Mercure for real-time updates.

Training Needed:

  • 1-hour workshop on Stimulus basics (controllers, actions, targets).
  • Symfony UX concepts (Turbo, Mercure) for advanced use cases.

Alternatives Considered:

  • Standalone Stimulus: More manual setup (e.g., custom Twig extensions, asset pipeline configs).
  • Alpine.js: Similar goals but less Symfony integration; may require more custom work.
  • React/Vue: Overkill for most use cases; introduces complexity and long-term maintenance costs.

StimulusBundle is the sweet spot for Symfony teams wanting modern interactivity without the overhead of full-stack frameworks. v3.6.0 does not change that, but teams must verify AssetMapper version compatibility before upgrading.


For Technical Leads:

"StimulusBundle is a high-leverage tool for Symfony teams looking to modernize their frontend without disrupting existing workflows. Here’s the technical breakdown:

Architecture Fit:

  • Decoupled Frontend: Stimulus controllers are self-contained and can be added incrementally to Twig templates.
  • Symfony UX Alignment: Integrates natively with Turbo (SPA-like navigation), Mercure (real-time updates), and AssetMapper (modern asset handling) on supported versions.
  • Twig-Centric: Reduces manual JS in templates by providing stimulus_* Twig functions for declarative behavior.
  • Service Integration: Helper service generates Stimulus data attributes dynamically.

v3.6.0 Compatibility Consideration:

  • A bug fix adds an explicit conflict with symfony/asset-mapper 8.2+. Treat this as a guardrail: validate the locked AssetMapper version in composer.json and CI before upgrading StimulusBundle.
  • Tooling dependency updates and debug:autowiring documentation improvements are non-breaking for typical applications.
  • If your platform roadmap includes AssetMapper 8.2+, plan for a compatible StimulusBundle release or temporary version pinning; otherwise current supported Symfony stacks can proceed normally.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource