README

This library implements an event dispatcher, based on Symfony's interface,
with wildcard syntax inspired by AMQP topic exchanges. Listeners may be bound to
a wildcard pattern and be notified if a dispatched event's name matches that
pattern. Literal event name matching is still supported.

If you are interested in using this library in a Symfony project, you may also
want to take a look at the corresponding bundle.

Internally, WildcardEventDispatcher actually composes an
EventDispatcherInterface instance, which it relies upon for event handling. By
default, WildcardEventDispatcher will construct an EventDispatcher object for
internal use, but you may specify a particular EventDispatcherInterface instance
to wrap in the constructor:

These event names all consist of two dot-separated words. This concept of a word
will be important in understanding how wildcard patterns apply.

In this example, the listener is responsible for observing all core events in
the application. Let's suppose it needs to log some details about these events
to an external server. We can refactor multiple addListener() calls by
using the single-word * wildcard:

The listener will now observe all events named core or starting with core.
and followed by another word. The matching of core alone may not make sense,
but this is implemented in order to be consistent with AMQP. A trailing *
after a non-empty sequence may match the preceding sequence sans .*.

Multi-word Wildcard

Suppose there was a core event in your application named core.foo.bar. The
aforementioned core.* pattern would not catch this event. You could use:

Additional Wildcard Documentation

When in doubt, the unit tests for ListenerPattern are a good resource for
inferring how wildcards will be interpreted. This library aims to mimic the
behavior of AMQP topic wildcards completely, but there may be shortcomings.

Documentation for actual AMQP syntax may be found in the following packages: