Smithery Logo
MCPsSkillsDocsPricing
Login
Smithery Logo

Accelerating the Agent Economy

Resources

DocumentationPrivacy PolicySystem Status

Company

PricingAboutBlog

Connect

© 2026 Smithery. All rights reserved.

    guillaumedelre

    symfony-7-4-event-dispatcher

    guillaumedelre/symfony-7-4-event-dispatcher
    Coding
    2
    1 installs

    About

    SKILL.md

    Install

    Install via Skills CLI

    or add to your agent
    • Claude Code
      Claude Code
    • Codex
      Codex
    • OpenClaw
      OpenClaw
    • Cursor
      Cursor
    • Amp
      Amp
    • GitHub Copilot
      GitHub Copilot
    • Gemini CLI
      Gemini CLI
    • Kilo Code
      Kilo Code
    • Junie
      Junie
    • Replit
      Replit
    • Windsurf
      Windsurf
    • Cline
      Cline
    • Continue
      Continue
    • OpenCode
      OpenCode
    • OpenHands
      OpenHands
    • Roo Code
      Roo Code
    • Augment
      Augment
    • Goose
      Goose
    • Trae
      Trae
    • Zencoder
      Zencoder
    • Antigravity
      Antigravity
    ├─
    ├─
    └─

    About

    Symfony 7.4 EventDispatcher component reference for event-driven communication between application components.

    SKILL.md

    Symfony 7.4 EventDispatcher Component

    GitHub: https://github.com/symfony/event-dispatcher Docs: https://symfony.com/doc/7.4/components/event_dispatcher.html

    Quick Reference

    Creating a Custom Event

    use Symfony\Contracts\EventDispatcher\Event;
    
    final class OrderPlacedEvent extends Event
    {
        public function __construct(private Order $order) {}
    
        public function getOrder(): Order
        {
            return $this->order;
        }
    }
    

    Dispatching an Event

    $event = new OrderPlacedEvent($order);
    $dispatcher->dispatch($event);
    

    Event Listener with #[AsEventListener] (Recommended)

    use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
    
    #[AsEventListener]
    final class OrderListener
    {
        public function __invoke(OrderPlacedEvent $event): void
        {
            // handle event
        }
    }
    

    Multiple Listeners on One Class

    use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
    
    final class MyMultiListener
    {
        #[AsEventListener]
        public function onOrderPlaced(OrderPlacedEvent $event): void { /* ... */ }
    
        #[AsEventListener(event: 'foo', priority: 42)]
        public function onFoo(): void { /* ... */ }
    }
    

    Event Subscriber

    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    use Symfony\Component\HttpKernel\KernelEvents;
    
    class StoreSubscriber implements EventSubscriberInterface
    {
        public static function getSubscribedEvents(): array
        {
            return [
                KernelEvents::RESPONSE => [
                    ['onKernelResponsePre', 10],
                    ['onKernelResponsePost', -10],
                ],
                OrderPlacedEvent::class => 'onPlacedOrder',
            ];
        }
    
        // ... handler methods
    }
    

    Stopping Event Propagation

    public function onPlacedOrder(OrderPlacedEvent $event): void
    {
        $event->stopPropagation();
    }
    

    Kernel Events

    • kernel.request (KernelEvents::REQUEST)
    • kernel.controller (KernelEvents::CONTROLLER)
    • kernel.response (KernelEvents::RESPONSE)
    • kernel.exception (KernelEvents::EXCEPTION)

    Debugging

    php bin/console debug:event-dispatcher
    php bin/console debug:event-dispatcher kernel.exception
    

    Full Documentation

    For complete details including service container integration, event aliases, before/after filters, listener vs subscriber comparison, all kernel event types, priority system, and advanced patterns, see references/event-dispatcher.md.

    Repository
    guillaumedelre/claude-skills
    Files