Download the PHP package contao-community-alliance/event-dispatcher without Composer

On this page you can find all versions of the php package contao-community-alliance/event-dispatcher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package event-dispatcher

Version Build Status License Downloads

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

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 are standard paradigm in software design.
  2. 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 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

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

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

/config/event_listeners.php

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.

/config/config.php

In your /config/config.php use $GLOBALS['TL_EVENTS'] to register your event handlers.

With a closure:

With a static callable:

With an object callable:

Handle with priority

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

Event listener per code

Event subscriber per configuration

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

/config/event_subscribers.php

We recommend to use this method!

The file /config/event_subscribers.php must return an array of subscribers.

/config/config.php

In your /config/config.php use $GLOBALS['TL_EVENT_SUBSCRIBERS'] to register your subscribers.

With a factory:

With an object class name:

With an object instance:

Event subscriber per code

Compatibility with Contao 3 & 4.

You are encouraged to register your events directly in the symfony event dispatcher in Contao 4 using service configuration files (yaml, xml, ...).

However, for maintaining compatibility, you still need to supply the event_listeners.php and event_subscribers.php files as otherwise the events will not get registered in Contao 3.

To register events only in Contao 3, we suggest to return an empty array if the version compare is equal to 4.


All versions of event-dispatcher with dependencies

PHP Build Version
Package Version
Requires php Version ^7.4 || ^8.0
contao/core-bundle Version ^4.9
symfony/config Version ^4.0 || ^5.4
symfony/dependency-injection Version ^4.0 || ^5.4
symfony/event-dispatcher Version ^4.0 || ^5.4
symfony/http-kernel Version ^4.0 || ^5.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package contao-community-alliance/event-dispatcher contains the following files

Loading the files please wait ....