承接 lium/event-dispatcher 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lium/event-dispatcher

Composer 安装命令:

composer require lium/event-dispatcher

包简介

Standard implementation of PSR-14 for event handling.

README 文档

README

A strict PSR-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 :

<?php

use App\Event\UserLoggedIn;
use Lium\EventDispatcher\EventDispatcher;
use Lium\EventDispatcher\ListenerProvider\DefaultListenerProvider;

// Listeners definitions
$listenerCalledForEveryEvent = function (object $event) {
    // This listener will match all events because its argument has the scalar type "object"
    echo sprintf('A listener has been called with the event "%s".', get_class($event));
};

$updateUserLastLoginDate = function (UserHasLoggedIn $event) {
    $user = $event->getUser();
    echo sprintf('The user "%s" has logged in.', $user->getUsername());
};

// Initialization
$listenerProvider = new DefaultListenerProvider([
    $listenerCalledForEveryEvent,
    $updateUserLastLoginDate,
]);

$eventDispatcher = new EventDispatcher($listenerProvider);

// Later in your code...
$eventDispatcher->dispatch(new UserHasLoggedIn($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 the examples directory to see more examples.

Contributing

See the CONTRIBUTING file.

License

This project is available with the MIT license. For the full copyright, thanks to read the license file.

统计信息

  • 总下载量: 11
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 13
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-12-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固