承接 ice-cream/events 相关项目开发

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

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

ice-cream/events

Composer 安装命令:

composer require ice-cream/events

包简介

Event Handler For Ice Cream Framework

README 文档

README

Build Status Packagist Maintenance Made With Love

Simple event handler for managing events in Ice Cream.

Requirements

  • PHP 7.2
  • Is Stand Alone

Documentation

You can view this packages documentation here

Usage

Usage is rather simple, first we have to create a listener and register it. A listener is going to listen for new events to be dispatched and then do something when that event is dispatched.

This is very similar to Symfony's event Dispatcher:

// Create the handler:

$eventHandler = new EventHandler();

// Create a listener to listen to events being fired:

$listener = new Listener();

Lets define the listener class:

use IceCreamEvents\Listener;

class PageViewEventListener extends Listener{

  // Read on to see the event definition.
  public function onAction(PageViewEvent $pageViewedEvent) {
     // ... Do something.
  }
}

Now lets create an event:

use IceCreamEvents\Event;

class PageViewEvent extends Event {

  protected $pageViewed;

  public function __construct(PageViewed $pageViewed) {
    $this->pageViewed = $pageViewed;
  }

  public function getPageViewed() {
    return $this->pageViewed;
  }
}

Finally lets register the event with the appropriate listener:

$eventHandler->register('page.viewed', PageViewEvent::class, PageViewEventListener::class, 'onAction');

Next we dispatch the event:

$eventHandler->dispatch('page.viewed');

What this does is register the page viewed event with the listener class and when the event is fired we call the onAction method and pass it the event class. This is similar to how Laravel registers events.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-20

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固