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 8364771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:30:20+00:00 2026-06-09T12:30:20+00:00

FYI I’m just getting started with Symfony, with that said… What advantage would there

  • 0

FYI I’m just getting started with Symfony, with that said…

What advantage would there be using a Listener as a Service instead of a Service?

Looking over the docs I see I can use a Listener as a Service:

  • http://symfony.com/doc/current/cookbook/service_container/event_listener.html

But I could also use the Event Dispatcher:

  • http://symfony.com/doc/current/components/event_dispatcher/introduction.html

to get the same functionality or am I missing something?

What I’m looking to do is create a service that listens for custom events and I’m a little confused on the route I should take with the above scenario. I have seen some posts about each setup but nothing comparing the two and the differences.

Thanks for any insight

  • 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-06-09T12:30:22+00:00Added an answer on June 9, 2026 at 12:30 pm

    In a nutshell, events in a Symfony application are similar to events in JavaScript: instead of listening to mostly UI related events (such as mouse clicks, hovers etc) you’re listening to arbitrary events in the application (such as exceptions getting throws, response being sent, user being created etc).

    EventDispatcher is built around the observer pattern. For any occurring events the dispatcher notifies all the registered listeners about the event. Surely you could retrieve the dispatcher from the service container and register the listener by hand, but this doesn’t allow us to listen to events being fired beforehand. Even worse, the listener is only registered in that controller action.

    By configuring the listener to be a service, you’re essentially letting the framework do the registering process itself. If you have a look at app/cache/dev/appDevDebugContainer.php (can be a bit different name, writing this off top of my head) and search for event_dispatcher, you should be able to see how the events have been automatically registered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider that I have 10 input boxes, (using datepicker plugin Fyi) I have a
I'm creating a simple application using the Kohana PHP framework, just FYI. This is
FYI, There is some overlap in the initial description of this question with a
* FYI: I'm not using Adsense and this is not against my TOS... I
This should be fairly simple; i'm pretty sure I've just not understood it. FYI,
FYI: SQL Server 2005 I have a database user account (user_web) that has the
I am working on a FYI page that has large list of top-tiered links.
[FYI, this is not homework — I guess everyone thinks that because I made
FYI, I'm working on my first MVC web application using MVC 3 and Razor
Just FYI this code is part of ExtJS 4 script. I have a global

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.