How can I see all available events in Symfony2?
I found a command on google
php app\console container:debug --show-private
But it does not show all available events. Like event named "security.interactive_login" is not listed in it. Is there a way to see available events?
You can run:
app/console debug:event-dispatcher
This will show you a detailed summary of every subscriber, in order of priority per event. Unfortunately this won't show you all possible events, since it's infeasible to query the container for any events that could be registered due to the inherently dynamic nature of the events system.
To understand events you'll need to refer to docs and code of each component and bundle.
Symfony standard ships with a multitude of events. Each Symfony component and bundle may or may not define events — your best bet is to look at each component or bundle's documentation for references to events.
Some very common events can be found in the docs:
I used PhpStorm to look for all subclasses of Symfony's base Event class (Symfony\Component\EventDispatcher\Event
).
I generated an inheritance tree each child is a subclass of it's parent.
* note: prepend Symfony\Component\ to find the FQN
I make no claim that these are all public events you can/should hook into — this is just one way to programmatic examine 3rd party code and get a sense for potential idioms.
For instance I noticed that both the HttpKernel, Security, and Console components use namespaced constants to expose their keys, see:
The container:debug command shows all services that are registered to the dependency injection container. With the parameter show-private it will also show services that are flagged with public=false.
So as the most events might not be services the command you are using will not give you a list of available events. But to give you a possibility to search for available events you could try the following command:
php app/console container:debug --show-private | grep -i "listener"
As the most event handlers might have the word listener in their definitions you will find many of them. If you then want to get a more detailed information about the events which are handled by those listeners just call the command with specifying the service ID. For example if you are working with the FOSUserBundle this will give you a description for the interactive login listener:
php app/console container:debug fos_user.security.interactive_login_listener
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With