PHPackages                             bit3/contao-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. bit3/contao-event-dispatcher

Abandoned → [contao-community-alliance/event-dispatcher](/?search=contao-community-alliance%2Fevent-dispatcher)ArchivedContao-module[Utility &amp; Helpers](/categories/utility)

bit3/contao-event-dispatcher
============================

Event dispatcher service for Contao Open Source CMS

03301PHP

Since Oct 30Pushed 12y ago1 watchersCompare

[ Source](https://github.com/bit3archive/contao-event-dispatcher)[ Packagist](https://packagist.org/packages/bit3/contao-event-dispatcher)[ RSS](/packages/bit3-contao-event-dispatcher/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

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)

Use `$GLOBALS['TL_EVENTS']` to register your event handlers.

With a closure:

```
$GLOBALS['TL_EVENTS']['event-name'][] = function($event) {
	// event code
};
```

With a static callable:

```
$GLOBALS['TL_EVENTS']['event-name'][] = array('MyClass', 'myCallable');
```

With an object callable:

```
$GLOBALS['TL_EVENTS']['event-name'][] = array(new MyClass(), 'myCallable');
```

#### Handle with priority

[](#handle-with-priority)

To define the priority, you can use an array with the listener as first and the priority as second element.

```
$GLOBALS['TL_EVENTS']['event-name'][] = array($listener, $priority);
```

### Event listener per code

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

```
$container['event-dispatcher']->addListener('event-name', $listener);
```

### Event subscriber per configuration

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

Use `$GLOBALS['TL_EVENT_SUBSCRIBERS']` to register your subscribers.

With a factory:

```
$GLOBALS['TL_EVENT_SUBSCRIBERS'][] = function($eventDispatcher) {
	return new MyEventSubscriber();
};
```

With an object class name:

```
$GLOBALS['TL_EVENT_SUBSCRIBERS'][] = 'MyEventSubscriber';
```

With an object instance:

```
$GLOBALS['TL_EVENT_SUBSCRIBERS'][] = new MyEventSubscriber();
```

### Event subscriber per code

[](#event-subscriber-per-code)

```
$container['event-dispatcher']->addSubscriber(new MyEventSubscriber());
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e61f74ea186c1e79e072b2974ccdeef39414730476d5a8adac501eb9449b2a3?d=identicon)[tril](/maintainers/tril)

---

Top Contributors

[![tristanlins](https://avatars.githubusercontent.com/u/343404?v=4)](https://github.com/tristanlins "tristanlins (8 commits)")[![discordier](https://avatars.githubusercontent.com/u/940331?v=4)](https://github.com/discordier "discordier (2 commits)")

### Embed Badge

![Health badge](/badges/bit3-contao-event-dispatcher/health.svg)

```
[![Health](https://phpackages.com/badges/bit3-contao-event-dispatcher/health.svg)](https://phpackages.com/packages/bit3-contao-event-dispatcher)
```

###  Alternatives

[branchonline/yii2-lightbox

Lightbox widget for Yii2

13139.0k1](/packages/branchonline-yii2-lightbox)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
