IntelliJ IDEA 2022.3 Help

Events

A good practice in applications design is making use of componentization and loose coupling. Ideally, components should have no knowledge of other components except for their interface or events. This allows reusing components over different applications or swapping out components with other implementations.

Symfony provides the EventDispatcher component that lets your application components communicate with each other by dispatching events and listening to them.

Install the required plugins

This functionality relies on the PHP, Symfony Support, and PHP Annotations plugins that should be installed and enabled in your IDE.

The plugins are available only in IntelliJ IDEA Ultimate.

  1. Press Ctrl+Alt+S to open the IDE settings and select Plugins.

  2. Switch to the Marketplace tab and use the search field to find the plugins.

  3. Click Install next to each plugin and restart the IDE if prompted.

Code completion in events

In the editor, press Ctrl+Space to invoke code completion and do any of the following:

  • Provide events' names to the relevant functions when dispatching or subscribing to events.

    Symfony events name completion
  • Provide events' names within an array of all events you're subscribing to, which is required for implementing EventSubscriberInterface.

    Symfony events array name completion

Code navigation in events

To navigate to the declaration of an event, position the caret at its usage and press Ctrl+B. Alternatively, Ctrl+Click the usage.

If several declarations are located, choose a specific one to navigate to from the popup menu.

Navigating to Symfony event declaration
Last modified: 01 August 2022