- Notifications
You must be signed in to change notification settings - Fork1
A strict PSR-14 implementation
License
NotificationsYou must be signed in to change notification settings
Lium-Framework/event-dispatcher
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
A strictPSR-14 implementation built with simplicity in mind.
The main goal behind this library is to be a strict implementation of the PSR-14.
composer require lium/event-dispatcherHere is a quick example to show you how to use it :
<?phpuseApp\Event\UserLoggedIn;useLium\EventDispatcher\EventDispatcher;useLium\EventDispatcher\ListenerProvider\DefaultListenerProvider;// Listeners definitions$listenerCalledForEveryEvent =function (object$event) {// This listener will match all events because its argument has the scalar type "object"echosprintf('A listener has been called with the event "%s".',get_class($event));};$updateUserLastLoginDate =function (UserHasLoggedIn$event) {$user =$event->getUser();echosprintf('The user "%s" has logged in.',$user->getUsername());};// Initialization$listenerProvider =newDefaultListenerProvider([$listenerCalledForEveryEvent,$updateUserLastLoginDate,]);$eventDispatcher =newEventDispatcher($listenerProvider);// Later in your code...$eventDispatcher->dispatch(newUserHasLoggedIn($user));
The previous example will output :
A listener has been called with the event "App\Event\UserLoggedIn".The user "johndoe" has logged in.You can check theexamples directory to see more examples.
See theCONTRIBUTING file.
This project is available with the MIT license. For the full copyright, thanks to read thelicense file.
About
A strict PSR-14 implementation
Topics
Resources
License
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.
Contributors2
Uh oh!
There was an error while loading.Please reload this page.