Download the PHP package silverstripe/event-dispatcher without Composer

On this page you can find all versions of the php package silverstripe/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

Event dispatcher for Silverstripe CMS

CI

This module provides a PSR-14 event dispatcher to Silverstripe CMS applications. It is useful for reactive programming paradigms in lieu of traditional imperative designs through hooks like onAfterWrite.

Most of the underlying work is handled by Symfony's EventDispatcher, but this can be replaced with through dependency injection.

Requirements

Installation

$ composer require silverstripe/event-dispatcher

Usage

There are three main components to the API:

Dispatching an event

The trigger function takes two arguments: string $eventName and EventContextInterface $context. The $context object can pass arbitrary data to any handlers that are subscribed to the event.

Event handling

Event handlers must implement EventHandlerInterface, which requires a fire() method.

Subscribing to events

The best way to register your event handlers with the dispatcher is through config.

Unsubscribing to events

To remove an event handler, override the config with an off node.

Managing events procedurally

To interact with the Dispatcher instance directly, use a DispatcherLoaderInterface.

Then, register the loader in Injector.

Action identifiers and context

Each of these handlers is passed a context object that exposes an action identifier. This is a string that provides specific information about what happened in the event that the handler can then use in its implementation. For instance, if you want to write event handlers for form submissions, where some handlers are for all form submissions, while others are for specific forms, you might pass the name of the form as an action identifier in your EventContext object.

Events are always called with eventName.<action identifier>. For instance formSubmitted.contact, allowing the subscribers to only react to a specific subset of events.

In this case, a contact form submission results in two handlers firing, in order of specificity (formSubmitted.contact first).

How to find your action identifier

The easiest way to debug events is to put breakpoints or logging into the Dispatcher::trigger() function. This will provide all the detail you need about what events are triggered when, and with what context.

When the logging is in place you just go to the CMS and perform the action you are interested in. This should narrow the list of identifier down to a much smaller subset.

Event context

In the above example, the contact form data is passed to the Event object as context.

In a handler, this can be accessed using the get(string $property) method.

Note that get fails gracefully, and will return null when a property doesn't exist.

License

See License

Bugtracker

Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.

If the issue does look like a new bug:

Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.

Development and contribution

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.


All versions of event-dispatcher with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
silverstripe/framework Version ^5
symfony/event-dispatcher Version ^6.1
psr/event-dispatcher Version ^1
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 silverstripe/event-dispatcher contains the following files

Loading the files please wait ....