PHPackages                             contao-community-alliance/event-dispatcher - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. contao-community-alliance/event-dispatcher

ActiveContao-bundle[Utility &amp; Helpers](/categories/utility)

contao-community-alliance/event-dispatcher
==========================================

Event dispatcher service for Contao Open Source CMS

2.1.1(10mo ago)2120.8k3[1 issues](https://github.com/contao-community-alliance/event-dispatcher/issues)20LGPL-3.0-or-laterPHPPHP ^7.4 || ^8.0CI passing

Since Dec 19Pushed 10mo ago7 watchersCompare

[ Source](https://github.com/contao-community-alliance/event-dispatcher)[ Packagist](https://packagist.org/packages/contao-community-alliance/event-dispatcher)[ Docs](https://c-c-a.org/)[ RSS](/packages/contao-community-alliance-event-dispatcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (16)Used By (20)

[![Version](https://camo.githubusercontent.com/82ca4019392a6bcbffe867d621d9868bd3046b5b89aff975dca72e6d4f645cd8/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f6e74616f2d636f6d6d756e6974792d616c6c69616e63652f6576656e742d646973706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/contao-community-alliance/event-dispatcher)[![Build Status](https://github.com/contao-community-alliance/event-dispatcher/actions/workflows/diagnostics.yml/badge.svg)](https://github.com/contao-community-alliance/event-dispatcher/actions)[![License](https://camo.githubusercontent.com/b92aac62c37f413d09408e957569bbef116982f21c440b9b855efa738980844d/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f6e74616f2d636f6d6d756e6974792d616c6c69616e63652f6576656e742d646973706174636865722e7376673f7374796c653d666c61742d737175617265)](http://spdx.org/licenses/LGPL-3.0+)[![Downloads](https://camo.githubusercontent.com/704bc4e19bdeaea6324b523853015aada291f6b015b9e6663a42f441949041b4/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f6e74616f2d636f6d6d756e6974792d616c6c69616e63652f6576656e742d646973706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/contao-community-alliance/event-dispatcher)

***NOTE:*** This is obsolete in Contao 4 - you should use the event dispatcher from the symfony kernel directly for Contao 4 only extensions. See below for maintaining compatibility with both Contao versions.

Event dispatcher for Contao Open Source CMS
===========================================

[](#event-dispatcher-for-contao-open-source-cms)

Why an event dispatcher for Contao Open Source CMS, are the hooks not enough? First you need to understand, there is no real difference between hooks and events. The are both notifications from within the system.

But events are more elastic than hooks. They can be hand round, consumed, stopped or bubble upon a hierarchy.

The real big reasons, why an event dispatcher exists for Contao are:

1. [Events](http://en.wikipedia.org/wiki/Event_%28computing%29) are standard paradigm in software design.
2. [Hooking](http://en.wikipedia.org/wiki/Hooking) is a paradigm to alter the behavior of a software, is it not designed for notifications.
3. Hooks are only a special form of events.
4. The [symfony event dispatcher](https://github.com/symfony/EventDispatcher) this extension based on is widely used.
5. The event dispatcher can handle every form of callbacks, like closures or static methods.

Listen on events
----------------

[](#listen-on-events)

The event dispatcher provide two ways to listen on events.

First and mostly used is an event listener. It is designed to listen on a single event.

Second the event subscriber is designed to listen on multiple events.

### Event listener per configuration

[](#event-listener-per-configuration)

Since version 1.3 there are two ways to define your listeners per configuration.

#### /config/event\_listeners.php

[](#configevent_listenersphp)

**We recommend to use this method!**

The file `/config/event_listeners.php` must return an array of event names as keys and listeners as values.

```
