Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A strict PSR-14 implementation

License

NotificationsYou must be signed in to change notification settings

Lium-Framework/event-dispatcher

Repository files navigation

A strictPSR-14 implementation built with simplicity in mind.

Why?

The main goal behind this library is to be a strict implementation of the PSR-14.

Installation

composer require lium/event-dispatcher

Usage

Here 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.

Contributing

See theCONTRIBUTING file.

License

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

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp