PHPackages                             shlinkio/shlink-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. shlinkio/shlink-event-dispatcher

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

shlinkio/shlink-event-dispatcher
================================

Simplifies registering async and regular PSR-14 event listeners while using RoadRunner.

v4.4.0(3mo ago)463.5k↓20.3%11MITPHPPHP ^8.4CI passing

Since Aug 12Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/shlinkio/shlink-event-dispatcher)[ Packagist](https://packagist.org/packages/shlinkio/shlink-event-dispatcher)[ Docs](https://shlink.io)[ RSS](/packages/shlinkio-shlink-event-dispatcher/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (23)Used By (1)

Shlink Event Dispatcher
=======================

[](#shlink-event-dispatcher)

This library simplifies registering async and regular [PSR-14](https://www.php-fig.org/psr/psr-14/) event listeners while using [RoadRunner](https://roadrunner.dev/).

Async ones are executed using RoadRunner jobs. This library takes care of the boilerplate of registering events as async tasks/jobs, and you just interact with plain PSR-14 listeners and events.

Most of the elements it provides require a [PSR-11](https://www.php-fig.org/psr/psr-11/) container, and it's easy to integrate on [mezzio](https://github.com/mezzio/mezzio) applications thanks to the `ConfigProvider` it includes.

[![Build Status](https://camo.githubusercontent.com/5ea576c89f8b3ec644fa845dabd861f8766e84b2b455f2de7ebba700710d0e0b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f73686c696e6b696f2f73686c696e6b2d6576656e742d646973706174636865722f63692e796d6c3f6272616e63683d6d61696e266c6f676f3d676974687562267374796c653d666c61742d737175617265)](https://github.com/shlinkio/shlink-event-dispatcher/actions/workflows/ci.yml?query=workflow%3A%22Continuous+integration%22)[![Code Coverage](https://camo.githubusercontent.com/47aafada70df2602ad2dfd9678ba8d9e2dffaa4968205ec12dca7ea1065a1e68/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f73686c696e6b696f2f73686c696e6b2d6576656e742d646973706174636865722f6d61696e3f7374796c653d666c61742d737175617265)](https://app.codecov.io/gh/shlinkio/shlink-event-dispatcher)[![Latest Stable Version](https://camo.githubusercontent.com/f5d07e233ca3ff0f6c28f03d4c6f4df45c8c5e21427b24b8b9769d2ab97f7826/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f73686c696e6b696f2f73686c696e6b2d6576656e742d646973706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/shlinkio/shlink-event-dispatcher)[![License](https://camo.githubusercontent.com/8e539bae91b5e77365a8f5e8d9875c4c1cdfc938a579ae4aefd66a92be1c9a0e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f73686c696e6b696f2f73686c696e6b2d6576656e742d646973706174636865722e7376673f7374796c653d666c61742d737175617265)](https://github.com/shlinkio/shlink-event-dispatcher/blob/main/LICENSE)[![Paypal donate](https://camo.githubusercontent.com/f7bd7ab1d7bea7a4ac78f5189c56ce2dbf8cc73608863e0dd9408e10ddca4673/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f446f6e6174652d70617970616c2d626c75652e7376673f7374796c653d666c61742d737175617265266c6f676f3d70617970616c26636f6c6f72413d616161616161)](https://slnk.to/donate)

Install
-------

[](#install)

Install this library using composer:

```
composer require shlinkio/shlink-event-dispatcher

```

> This library is also a mezzio module which provides its own `ConfigProvider`. Add it to your configuration to get everything automatically set up.

Usage
-----

[](#usage)

This module allows to register both regular and asynchronous event listeners on a PSR-14 EventDispatcher.

Regular listeners are executed on the same process, blocking the dispatching of the HTTP request, while asynchronous listeners are delegated to a RoadRunner job, making the request to resolve immediately.

If RoadRunner is not found, async listeners are ignored by default, but you can choose to make them to be registered as regular listeners instead.

> **Note**In order to be able to integrate with RoadRunner jobs, you need to install `spiral/roadrunner-jobs`.

In order to register listeners you have to use a configuration like this:

```
