Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7547351
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T09:25:55+00:00 2026-05-30T09:25:55+00:00

I am starting developing with Symfony2 framework and I like to use the Eventdispatcher.

  • 0

I am starting developing with Symfony2 framework and I like to use the Eventdispatcher. Now I have three questions I could find an answer with google yet.

  1. Where I place the dispatcher so it is accessable from everywhere in
    tha app?

  2. How I can configure customevents? Should I place all in one file or
    one for each bunble?

  3. How much effort is it to configure it with annotations, i.e
    @Event("some.event")? Is that possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T09:25:56+00:00Added an answer on May 30, 2026 at 9:25 am

    General

    I might suggest the Symfony 2 documentation on the EventDispatcher as a good starting point, assuming that you mean you wish to provide custom events rather than a custom event dispatcher.

    Symfony2 Internals – The Event Dispatcher

    Location of Events

    In terms of location, an ‘Event’ folder within the appropriate bundle is a good choice. It is likely that the actual dispatching of the event will take place only within the bundle context, whereas listeners may reside elsewhere. This is however a separate topic and of minimal relevance as they simply subscribe to the event’s string-name (e.g., ‘store.order’ to borrow the documentation’s example) and only require knowledge of the Event’s interface/type.

    So you might have an Event called ‘Foo’ within the ‘Bar’ bundle in ‘Zap’ namespace:

    namespace Zap\Bar\Event;
    
    use Symfony\Component\EventDispatcher\Event;
    
    class FooEvent extends Event
    {
        // ...
    }
    

    When you then come to dispatch an event from within your bundle, you might choose to use the event identifier ‘zap.bar.foo’, and of course you can then register listeners from elsewhere to be notified on this identifier as you see fit.

    Accessing the Event Dispatcher

    Where you wish to access the primary EventDispatcher instance, acquire access to the Dependency Injection Container and retrieve the ‘event_dispatcher’ service. A simple approach is to have your class extend ‘ContainerAware’ and then retrieve the dispatcher with

    $dispatcher = $this->container->get('event_dispatcher');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am just starting out developing PHP web applications and have finished setting
Starting a new project and would like to use one of the MVC framworks.
I´m starting to developing with cake php. I have designed a DB model and
Hi I'm starting with android developing, and I have to create a login form
Hi I'm starting with android developing, and I have to create a login form
I'm starting developing applications for iPhone. My idea is to develop a application like
I'm starting developing a Web Site for a Sport Club. This site will have
I'm a C++ developer over 5 years. Now I'm starting developing for android, but
I am looking for some good starting point for developing web-service. I have one
I am starting to use Eclipse for C++ developing after years with Visual Studio.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.