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 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

Product Decisions This Supports

  • Frontend Modernization Without Disruption Adopt StimulusBundle to gradually enhance Symfony applications with interactive UIs while avoiding the overhead of full-stack JavaScript frameworks. Ideal for teams prioritizing performance, maintainability, and incremental adoption—especially in legacy systems or monolithic apps where a full rewrite is costly.

  • Symfony UX Ecosystem Adoption Use StimulusBundle as the foundation for Symfony UX integration, enabling seamless adoption of Turbo (SPA-like navigation), Mercure (real-time updates), and Dropzone (file uploads). Reduces friction in transitioning from traditional Symfony + jQuery to a modern, component-driven frontend stack.

  • Build vs. Buy Decision Buy: StimulusBundle eliminates the need to manually configure Stimulus with Symfony’s asset pipeline, Twig templates, or dependency injection. Build: Only if requiring custom Stimulus integrations (e.g., hybrid architectures with React/Vue or non-Symfony backends) that exceed the bundle’s scope.

  • Roadmap Prioritization

    • Phase 1: Replace jQuery plugins or vanilla JS with Stimulus for progressive enhancement (e.g., dynamic forms, modals, tooltips).
    • Phase 2: Integrate with Symfony UX components (e.g., Turbo for navigation, Mercure for real-time updates) to reduce reliance on heavy JS frameworks.
    • Phase 3: Standardize Stimulus across microservices or monolithic apps for consistency and shared frontend patterns.
  • Key Use Cases

    • Admin Panels: Dynamic tables, collapsible sections, or real-time dashboards (e.g., with Mercure).
    • E-Commerce: Interactive product filters, cart updates, or multi-step checkout flows.
    • Legacy Modernization: Gradually enhance older Symfony apps with Stimulus instead of full rewrites.
    • Internal Tools: Build lightweight, interactive tools (e.g., data visualization, workflow builders) without frontend framework overhead.

When to Consider This Package

Adopt StimulusBundle If:

  • Your team uses Symfony 7.4+ and wants to modernize frontend interactions without adopting a full JS framework.
  • You prioritize performance and bundle size (Stimulus is ~10KB gzipped vs. 100KB+ for React/Vue).
  • Your roadmap includes Symfony UX (Turbo, Mercure, AssetMapper) and you want seamless integration.
  • You need Twig-native Stimulus controllers/actions (e.g., {{ stimulus_controller('example') }}) to reduce manual JS wiring.
  • Your frontend team is small or prefers modular, convention-over-configuration JavaScript.
  • You’re targeting progressive enhancement (e.g., dynamic forms, modals, real-time updates) rather than full SPA behavior.
  • Your app requires interactive UIs but lacks complex state management (Stimulus is not a replacement for Redux or NgRx).

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, nested context providers) beyond Stimulus’s scope.
  • You don’t use Symfony (StimulusBundle is Symfony-specific; consider 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 what Stimulus + Mercure can offer (e.g., custom WebSocket integrations).
  • Your frontend stack relies heavily on non-Symfony tools (e.g., Laravel Mix, Vite, or custom Webpack setups with minimal Twig integration).

How to Pitch It (Stakeholders)

For Executives:

"StimulusBundle lets us deliver faster, more interactive user experiences without the complexity or cost of heavy JavaScript frameworks. By integrating Stimulus with Symfony—our existing backend—we can modernize features like admin dashboards, checkout flows, or real-time updates with minimal risk and low development overhead.

This approach reduces technical debt by avoiding fragmented frontend stacks (e.g., jQuery + React + Vue) and aligns with Symfony’s long-term strategy for frontend development. We can start small—replacing simple JavaScript widgets—and scale to advanced interactivity as needed, all while keeping development costs predictable and maintainable.

Key Outcomes:

  • Faster Time-to-Market: Build interactive features in weeks, not months.
  • Lower Development Costs: Leverage existing PHP/Symfony teams; no need for specialized frontend engineers.
  • Scalable Architecture: Start with progressive enhancement and evolve to SPA-like behavior with Symfony UX (e.g., Turbo for navigation).
  • Future-Proof: Aligns with Symfony’s roadmap, reducing risk of tech debt from proprietary or overly complex solutions."

For Engineering Teams:

"StimulusBundle provides a zero-boilerplate way to add Stimulus.js to Symfony applications. It handles all the heavy lifting—from Twig integration to asset pipeline compatibility—so we can focus on building features, not configuring tools.

What It Solves:

  • No More Manual JS Integration: Automatically generates Stimulus data attributes in Twig templates (e.g., {{ stimulus_controller('example') }}).
  • Seamless Symfony UX Integration: Works out-of-the-box with Turbo, Mercure, and AssetMapper, enabling modern frontend patterns without rewriting the backend.
  • Modular JavaScript: Stimulus controllers are small, reusable, and easy to debug compared to monolithic frameworks.
  • Progressive Adoption: Start with simple interactions (e.g., modals, tooltips) and scale to complex UX as needed.

Why Not DIY?

  • Avoid reinventing Stimulus + Symfony integration (e.g., manual Webpack configs, Twig extensions, or asset pipeline tweaks).
  • Leverage Symfony’s ecosystem (e.g., Mercure for real-time updates, Turbo for navigation) without vendor lock-in.
  • Reduce context-switching: Stimulus controllers live alongside PHP services, making them easier to maintain than standalone JS files.

Getting 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.

Training Needed:

  • Familiarity with Stimulus.js (controllers, actions, targets) is required but low-effort to learn.
  • Symfony UX concepts (e.g., Turbo, Mercure) are optional but recommended 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."


For Technical Leads:

"StimulusBundle is a high-leverage tool for Symfony teams looking to modernize their frontend without disrupting existing workflows. Here’s how it fits into our stack:

Architecture Benefits:

  • 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).
  • Twig-Centric: Reduces manual JS in templates by providing stimulus_* Twig functions for declarative behavior.

Integration Risks & Mitigations:

Risk Mitigation
Stimulus Learning Curve Provide a 1-hour workshop on Stimulus basics (controllers, actions, targets).
AssetMapper Migration Test locally before deploying; use excluded_patterns to avoid breaking existing assets.
Debugging Complexity Standardize on Symfony Profiler + Browser DevTools for Stimulus actions.
Twig Template Changes Audit templates for onclick handlers or inline JS; replace with stimulus_* functions.

Migration Path:

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

Performance Impact:

  • Bundle Size: Stimulus is ~10KB gzipped; minimal impact on page load.
  • Asset Pipeline: AssetMapper adds ~500ms to build time (one-time cost).

Long-Term Viability:

  • Backed by Symfony’s team and aligned with their UX roadmap.
  • TypeScript Support:
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope