The Event-Driven Messaging is a design pattern, applied within the service-orientation design paradigm in order to enable the service consumers, which are interested in events that occur within the periphery of a service provider, to get notifications about these events as and when they occur without resorting to the traditional inefficientpolling based mechanism. by. wiki
In PHP there are different implementation of this pattern, but I tried to write my idea. An easy to understand and to extends event manager based on regex.
Why? Because it is a good way to match strings, it is flexible and powerful. As it is smart and little and it can be used as basis for custom implementation. it resolves a regex and triggers events It supports a priority to order triggered listeners.
Each listener has a priority (default = 0), it describe the order of execution
I wrote this library because there are a lot of solutions that implement this pattern but they are verbose, this is only an event manager if you search other features you can extends it or you can use differents implementations. On top of this library you can write your library to build an event manager ready to use with your team in your applications.
This is a good solution because it is easy, ~31 line of code to trigger events without fear to inherit many line of codes and unused features to maintain.
did you enjoy the article? Buy me a coffe
or share the content